📜  laravel 获取倒数第二条记录 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:53.850000             🧑  作者: Mango

代码示例4
$row = News::count();
        $newsid = $row -2;
        $news1 = News::all()->last();
        $news2 = News::orderBy('created_at', 'desc')->skip($newsid)->take($newsid)->first();
        return view('user/start', compact('news1', 'news2', 'newsid'));