Here is my controller function where i am paginating my results
public function showallUsers() {
$user = User::getUsers()->simplePaginate(5);
return view('sellerTable', compact('user'));
}
I am using Eloquent queries in my models to get data from database , here is my getUser method in the User model.
protected static function getUsers() {
$data = User::where('role', '=', 'seller')
->where('archive', '=', 0)->get(['id', 'user_name', 'first_name', 'last_name', 'phone_no', 'gender', 'facebook_id', 'gmail_id', 'email', 'braintree_customer_id', 'role']);
return (!empty($data)) ? $data->toArray() : array();
}
When i use to hit my controller function the following error comes
Call to a member function simplePaginate() on array
It is comming because i am returning an array in Model User to UserController . Laravel is not allowing me to call a simplePaginate Function on an array , any ideas that how can i call laravel Paginator on an array ?