Answers for "laravel get next record"

PHP
0

laravel get next record

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);
}
Posted by: Guest on September-04-2020

Code answers related to "laravel get next record"

Browse Popular Code Answers by Language