Good afternoon. I have a count that seems to work but it's not visible in the blade.
In the Controller:
public function render()
{
$projekte = Project::orderBy('id','desc')->paginate(10);
$count = Project::withCount('games')
->get();
//dd($count);
return view('livewire.projects.project-overview', compact ('projekte','count'));
}
in the blade
@foreach($projekte as $project)
<p>{{$project->games_count}} </p>
@endforeach
If I DD the $games I can see the correct amount.
I don't understand what's wrong.
You are printing the verifiable "$count" and accessing the project variable in the view file.
You can act in this manner.
$projekte = Project::withCount("games")->latest()->paginate(10);
After that, you can access the file in your view as follows.
@foreach( $projekte as $project )
<p>{{ $project->games_count }}</p>
@endforeach
Happy Coding!...