Dibyaranjan Dibyaranjan - 1 year ago 117
PHP Question

Laravel change id column to userId in users table

i am trying to change the id of users table to userId, but laravel authentication mechanism always checks for id column of users table.like

Users::check() and Users::attempt()

these functions always check for id attribute of users table, how to change this behavior of laravel.

Answer Source

To override the primary key used to search you must define the primaryKey property on the User model.

protected $primaryKey = 'userId';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download