Error on Delete action
I get an error when deleting a record from a resource. The recording is deleted, but this error still appears. At the same time, if you delete through the table using bulk action, then there is no such error.
Error: Call to a member function getKey() on null
Solution:Jump to solution
Working fine with custom action and query like DB::table(‘tags’)->where(‘id’, $record->id)->delete();
12 Replies
Do you have a delete action?
Yes. Default Filament delete action generated for resource
Sounds like you must have forgein keys or similar and it's trying to remove it can can't get the id essentially
The record is deleted successfully, judging by the logs. But at the same time I get this error.
So you have a tags relationship?
Do you have a belongsToMany for tags opposed to hasMany ?
That's likely why, I could be wrong but a record shouldn't belong to many. It should have many tags, by belonging to many tags it'll try and update/delete them.
If i use hasMany i can`t use select relationships
And why then if you delete through the list using bulk action, there is no error?
I am unsure, are you using a custom tags model? I was assuming you were using spatie tags
Custom
Any ideas?
Solution
Working fine with custom action and query like DB::table(‘tags’)->where(‘id’, $record->id)->delete();