it should be
$userUpdate = DB::select('SELECT * FROM users WHERE id = ?', [$id])->get();
$userUpdate will return the results as a collection. You need to loop that. to get just the first result you can use first() method
if the collection is empty, you will again get the same error, to fix that use:
$userUpdate->first() ?: $userUpdate->first()->name;
Thank you for your response I just fixed it using the query builder
$userInfo = DB::table('users')->where('id', $id)->first(); return view('users.update', ['userInfo' => $userInfo]);
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us
The Laravel portal for problem solving, knowledge sharing and community building.