Sort unpaged list in php laravel

2

I'm organizing some list objects by their names, but I want to sort them without having to page them. The code that 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 Employees without the need of the method (paginate). How could I solve it?

    
asked by Asdrubal Hernandez 03.10.2018 в 00:56
source

1 answer

1

To bring the records without pagination, simply use the get() method:

Employee::orderBy('first_name', 'ASC')->get();

You can review the documentation here:

link

    
answered by 03.10.2018 / 12:00
source