Prakhar Singh Prakhar Singh - 9 months ago 83
MySQL Question

Select second last record with Laravel - eloquent

How can i select the next to last record added to a table. I can select the last record like -

transition::order_by('created_at', 'desc')->first();

Answer Source

Try this:

transition::orderBy('created_at', 'desc')->skip(1)->take(1)->get();