Laravel - Database Basics and Migrations
Identify the error in this Laravel database query code:
$user = User::where('email', $email)->get();
return $user->name;$user = User::where('email', $email)->get();
return $user->name;get() returns a collection (list), not a single object.$user->name fails because $user is a collection, not a User object.get() returns a collection, not a single user object. -> Option Cget() = collection, not single object [OK]get() returns many; use first() for one [OK]get() returns one objectwhere is misspelled15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions