laravel get first record

43

how to get just the first row from a table in laravel -

$user = User::whereEmail($email)->first();

laravel query builder select first -

$user = DB::table('users')->where('name', 'John')->first();

var_dump($user->name);

collection get first element laravel -

$first = $msgs->first(); // this does ->take(1) under the hood

Comments

Submit
0 Comments