Support the ongoing development of →
Database Views Installation
Last updated 1 year ago.

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;
Last updated 7 years ago.

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!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.