im trying to retrive the users on page mount and paginate them using the following code:
public function mount()
{
$this->users = User::where('register_completed', '1')->paginate(16);
}
but im getting this error:
Livewire component's [user-search] public property [users] must be of type: [numeric, string, array, null, or boolean]. Only protected or private properties can be set as other types because JavaScript doesn't need to access them.
The plan is to load all of the users using mount
on page load and then let the user filter them using a filter form with multiple criteria. the paginator works using this code:
public function render()
{
return view('livewire.user-search', [
'users' => User::where('register_completed', '1')->paginate(16),
])
->extends('layouts.app')
->section('content');
}
but I need to use a specific function to filter the results based on the selected criteria. also, the search is not real-time and there is a button to call the search filter function. not sure why pagination only works when passed through the render
method. also, the $users
is a public property to access it from the view.
I believe it has something to do with livewire pagination because the same code works once I remove the paginate(16)
from the component and the $users->links()
from the view but still can’t figure out how to resolve this issue.