I'm organizing some list objects by their names, but I want to sort them without having to paginate them. The code I have is the following:
if ($filter['sort'] == 'name_asc'){
return Employee::orderBy('first_name', 'ASC')->paginate(1000);
} else if ($filter['sort'] == 'name_desc') {
return Employee::orderBy('first_name', 'DESC')->paginate(1000);
}
But I want to return the Employee without needing the method (paginate). how could i solve it?
To fetch the records without pagination simply use the method
get()
:You can review the documentation here:
https://laravel.com/docs/5.7/queries#retrieving-results