I have a Laravel application, I have a database table with 780950 registers, so, when I retrieve this with eloquent it takes a long long time and then gives time exceeded error. Is there a way to retrieve for example the first 30 records? I tried with this:
mymodel::all()->take(30)->get();
But is the same. So then, I just put:
mymodel::where('id','<','30')->get();
And it works, but it's not what I want because I want to paginate and display all the records. So, I know that it's a lot of records, but if I can retrieve the first 30 and then with ajax retrieve another 30 more. So what is the best and more elegant way to achieve this in Laravel 5.3?