📌  相关文章
📜  laravel 获取下一条记录 - PHP 代码示例

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

代码示例1
public function show($id)
{

    // get the current user
    $user = User::find($id);

    // get previous user id
    $previous = User::where('id', '<', $user->id)->max('id');

    // get next user id
    $next = User::where('id', '>', $user->id)->min('id');

    return View::make('users.show')->with('previous', $previous)->with('next', $next);
}