Reputation: 669
I have changed the primary key in a table from id to pr_id and mobile.
$table->primary(['pr_id' , 'mobile']);
also I added SoftDelete Trait in model. but when I want to delete a record it doesn't work.
Upvotes: 5
Views: 372
Reputation: 1301
You need to override few methods also like getKeyForSaveQuery, setKeysForSaveQuery
with defining the primary key in model. For soft delete you need to override one more method runSoftDelete
.
Reference links
Upvotes: 1
Reputation: 3541
I believe this is because of not mentioning primary key into model, and your model still consider primary key is id
however you have changed it. So you just to add following script into relevant model,
class YourModelClass extends Model
{
protected $primaryKey = 'pr_id';
}
This in way model won't consider primary key as id
.
Upvotes: 3