0
votes

I'm beginer in laravel. I have table tbl_user with user_id is pramary key.

User Model:

protected $table = 'tbl_user';
public $timestamps = false;

protected $fillable = [
    'user_id','name', 'email', 'password',
];
protected $primaryKey = 'user_id';
protected $hidden = [
    'password', 'remember_token',
];

When I checked user login by Auth:check() it show error message

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from tbl_user where id = 1 limit 1) (View: C:\xampp\htdocs\CMM\04.Development\resources\views\request\requestDetail.blade.php)

1
Is there a particular reason why you are using user_id instead of id as your primary key? - thisiskelvin

1 Answers

0
votes

Change your SQL to

select * from tbl_user where user_id = 1 limit 1

You need to use user_id instead of ID in where clause as the table has column name user_id not id.