mercredi 10 juin 2020

Laravel 5: Grabbing a single record from a query using `take`

Right now, I am using Eloquent like this: MobileAppUsers::where('store', '=', 'store_name')->first(); It turns out I don't need to check the store_name because the entire table is within that store's database, so I just want the single record that will be there (there will only be 1).

Without changing any other logic, would the equivalent of MobileAppUsers::where('store', '=', 'store_name')->first(); be : MobileAppUsers::take(1)->get(); ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire