Feb 4, 2025
7
Level 1
Undefined Variable Livewire problem
he say always that: Undefined variable $count
the php livewire class
<?php
namespace App\Livewire\Course;
use Livewire\Component;
class Index extends Component
{
public $count = 'hello';
public function render()
{
return view('livewire.index');
}
}
the blade view
<div>
{{$count}}
hello from the index
</div>
the route
Route::view('/test', 'livewire.index');
Level 102
@Daghsny Yes. It isnt set. If you call the view directly, livewire has no clue it has to do anything. Do one of the solutions I already suggested..
Also your code is wrong. Its get() not view()
Route::get('/test', TestIndex::class);
And why is it now TestIndex? Your first post said it was called Index ?
1 like
Please or to participate in this conversation.