I have a problem with my Laravel project in using blade component.
When I define a new component and want to use "Component public Methods" to pass data to "view component blade file", I receive an error, "Undefined variable"
The component has been made by
php artisan make:component testc
and i try
cache:clear
view:clear
and composer dump
before
and has following codes:
component code
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class testc extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return view('components.testc');
}
public function test()
{
return 'test';
}
}
view component blade file
<div>
{{ $test }}
</div>
and my error
ps: laravel version is : 7.18.0