the dafault code for the id column for the users table is like such:
**$table->id();**
But I changed in to: $table->bigIncrements('user_id');
Now i got error saying that 'id' column is not found in a file that doesnt run the query for users table at all. I dont know where i'm wrong.
Or is the id column is unchangeable after all since it is package?
CodePudding user response:
$user->id() default checks for primary key column 'id'.
So you can rename your primary key in your model like this :
protected $primaryKey = 'user_id';
CodePudding user response:
id()
is a is an alias of the bigIncrements method. so you can write it like
$table->id('user_id');
CodePudding user response:
Please just go to your Model and add below line of code, it'll solve your problem.
it's because laravel by default searches for id and it doesn't find it because you've changed it, if you want to let the Laravel know that your primary key is not id but 'user_id' you should add it in your model that Laravel should get it from there.
protected $primaryKey = 'user_id';
that is it.