Support the ongoing development of Laravel.io →
Database Views Installation
Last updated 2 years ago.
0

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

$userUpdate->first()->name;

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.
0

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]);
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.