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

Tempory comment out this line

return View::make('user.edit')->with('user', $user);

And do a

print_r($user);

That will let you know if it's successfully getting through the query.
If no results here troubleshoot if $user_id is being passed to the method.
You could comment out everything in method and

echo $user_id;

If that echoes and the print_r shows a results, then double check your query.

Last updated 2 years ago.
0

Also here is a youtube video on editing a database record in laravel.
https://www.youtube.com/watch?v=q0t6JIY707A

Last updated 2 years ago.
0

This may sound like a silly question, but is the name of your table user or users? That would be why the database query is failing (SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.id' in 'where clause' (SQL: select * from users where users.id = 2 limit 1)), what if you change your query to:

DB::table('user')->where('user_id', '=', $user_id)->first();

What does your User model look like, do you set the protected $table; property?

Last updated 2 years ago.
0

Thank you very much for the answers. I found the problem, my primary ky is user_id, and laravel by default uses id for all tables Ids, so I added this line to my user model and that works perfect.

protected $primaryKey = 'user_id';

Thank you. cheers

0

you guys are a life saver. The last solution worked as a magic.... Thank you so much juanpscotto...

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.