How to make custom delete if the primary key is "key" not id?

This is my model
protected $primaryKey = 'key';

public $incrementing = false;

protected $keyType = 'string';

protected $fillable = [
'key',
'value',
'scope',
'label',
'description',
'type',
'options',
'is_readonly',
];

//I already add this for the delete but not working

public function getRouteKeyName(): string
{
return 'key';
}
protected $primaryKey = 'key';

public $incrementing = false;

protected $keyType = 'string';

protected $fillable = [
'key',
'value',
'scope',
'label',
'description',
'type',
'options',
'is_readonly',
];

//I already add this for the delete but not working

public function getRouteKeyName(): string
{
return 'key';
}
and this the table action
Tables\Actions\DeleteAction::make(),


\\I also try this but not working

Tables\Actions\DeleteAction::make()
->requiresConfirmation()
->action(function ($record) {
$record->delete();
return Redirect::route('filament.admin.resources.settings.index');
})
Tables\Actions\DeleteAction::make(),


\\I also try this but not working

Tables\Actions\DeleteAction::make()
->requiresConfirmation()
->action(function ($record) {
$record->delete();
return Redirect::route('filament.admin.resources.settings.index');
})
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?