Hello Friends 👋,
Welcome To Infinitbility! ❤️
this article explain how to Select only first row or single row in laravel.
laravel provide first()
method to Select only single row using first()
you will not required to write like this $array[0]
.
If you just need to retrieve a single row from a database table, you may use the DB facade’s first method. This method will return a single stdClass object:
1$user = DB::table('users')->where('name', 'John')->first();23return $user->email;
Thanks For Reading…
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.