我想通过在 Laravel 中使用 Eloquent 从 mysql 表中选择所有行,除了最近的行。 我目前这样做只是为了获取最新的条目,但我希望做相反的事情:
Table::orderBy('created_at', 'desc')->first();
知道我该怎么做吗?
最佳答案
你可以使用 laravel 集合的 shift 方法。
$data = DB::table('your_table')->orderBy('created_at', 'desc')->get();
$data->shift(); //which removes the first element. now $data has all other values except for first one.
关于mysql - 在 Laravel 中使用 Eloquent 选择数据库中除最新行以外的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65832659/