Bulk Deleting on not migrated Tables
Hello I have a Problem, I have a resource on filament that have belongs to a model that does have a "not migrated" table. it means the table created manually or by other applications.
the problem is when users select some of records on Table (I mean the table of filament) and then Bulk Deleting them, all records gets Deleted.
there are some things to note:
- as I said the table not migrated by Laravel and I really can't to that
- the table does'nt have ID Column. maybe this thing cause all records gets Deleted. if it is, how I can change it to other Column?
I Don't know it's gonna be a bug or something else... but if there is a way to fix, Please tell me how I can fix that. tysm
Solution:Jump to solution
Of course, the delete statement will be "delete from table where primary_key = 'value'". If every row has the same value.......
9 Replies
I assume the table has a primary key column with some name other than "id". If that is the case, all you might need to do is specify the primary key on the model:
well, i set timestamps = false, but still not working.
Did you define the primary key? That is the important bit. That is how you change it to other Column.
yea i already defined that before
That normally works for me. I assume the column you are using contains unique entries, even if it isn't the primary key? A unique key at least?
it should be unique?
Solution
Of course, the delete statement will be "delete from table where primary_key = 'value'". If every row has the same value.......
well, the primary key of mysql table is other column. should i change the model's primary key to the mysql one?
oh
it worked!!!!!!
TYSM!
π