How can I get the first record with larvel 4 raw requests.
Something like DB::select('')->first(); does not work and DB::first('')
DB::select('')->first();
DB::first('')
The fact is that DB: select () returns an array, so you need to:
DB::select(DB::raw('select * from users'))[0];
you also can
DB::table('users')->first();
Like this:
DB::table('users')->take(1)->get()[0];
DB::table('users')->first(0);
When using eloquence, you can do this:
$user = User::take(1)->get();