Answers for "laravel last()"

PHP
4

laravel get last 5 records

Dogs::latest()->take(5)->get();
Posted by: Guest on May-23-2021
1

array_last in laravel 8

use Illuminate\Support\Arr;

$array = [100, 200, 300, 110];

$last = Arr::last($array, function ($value, $key) {
    return $value >= 150;
});

// 300
Posted by: Guest on September-21-2021
0

eloquent using last()

Model::latest()->first();
Posted by: Guest on November-03-2020

Browse Popular Code Answers by Language