I try to fetch posts from a database and display them in a blade file, but I get the error foreach() argument must be of type array|object, null given Why?
UserList.php, render()
public function render(): View
{
$usersQuery = TeamUser::query()
->select(['team_user.*'])
->where('team_id', Auth::user()->team_id);
$paginatedUsers = $usersQuery->paginate(10);
// Pass the paginated results to the view
return view('livewire.users-list', ['teamUsers' => $paginatedUsers]);
}
users-list.blade.php
@foreach($teamUsers as $teamUser)
//display each user...
@endforeach