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.
Also here is a youtube video on editing a database record in laravel.
https://www.youtube.com/watch?v=q0t6JIY707A
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?
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
you guys are a life saver. The last solution worked as a magic.... Thank you so much juanpscotto...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community