Filament ignoring foreign key constraints
Pretty simple, i have a foreign key constraint on a table, but filament is able to delete records i'm not allowed to delete in the database? Is there some sort of option I need to enable?
6 Replies
Sorry, what do you mean
filament is able to delete records i'm not allowed to deleteI don't think it's possible for filament to know what constraints you have in the database. You will have to either check manually or add some sort of validation.
I mean..
somehow filament disables the constraints?
i was expecting a 500 error, but i was allowed to delete it
which is super weird imo
If you have a constraint in the database (I assume a foreign key or something similar), filament should not be able to remove it, unless they do some REALLY funky stuff behind the scenes - which I doubt.
Are you sure there's not something else going on?
Can you give add some examples? Like the migration definition and the code that should fail?
code is just a basic delete action on the store resource
and then i have these constraints:
i would love to know why these don't work for filament
Shouldn’t you have ->constrained() on there too? Or use ->restrictOnDelete()
Solution
i found out why it didn't work, i was using soft deletes 🙂