how can I check if the current record is the last one in the model?
JavaScript
$lastorder=Order::find($order_id);
if($lastorder->last())
Advertisement
Answer
JavaScript
$orders = Order::where('id','>=', $order_id)->get();
$order = $orders->first();
if($orders->count() > 1) {
//...
// NOT the last record :(
//...
} else {
//...
// Last record :)
//...
}