I have made a laravel component using php artisan make:component testcomponent
for which two files are created; one is blade and second one is php class file.
here is the blade file:
<div>
{{ $data }}
</div>
and here is the php file
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class testcomponent extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.testcomponent');
}
}
And i called this component in a blade file using this way <x-testcomponent/>
But Now, how can i pass a variable coming form controller to this component?