Policy not applying on custom action

I have a custom filament class that extends filament table action. Its purpose is to update the record. Everything works the way it's expected apart from the policies not being applied. Here's an outline of the action:
class EditDiscountAction extends Action
{
protected function setUp(): void
{
parent::setUp();

$this->name('edit-discount');

$this->label('Edit Discount');

$this->icon('heroicon-o-pencil');

$this->slideOver();

$this->modalHeading('Edit Discount');

$this->modalSubmitActionLabel('Edit Discount');

$this->modalFooterActionsAlignment(Alignment::End);

$this->successNotificationTitle('Discount updated successfully.');

$this->failureNotificationTitle('Something went wrong.');

$this->modalWidth(MaxWidth::Medium);

$this->fillForm(function (Model $record): array {
return $record->attributesToArray();
});

$this->action(function (Model $record, array $data) {
// action implementation
}

public function getForm(Forms\Form $form): ?Forms\Form
{
return DiscountForm::getFormFields($form);
}
}
class EditDiscountAction extends Action
{
protected function setUp(): void
{
parent::setUp();

$this->name('edit-discount');

$this->label('Edit Discount');

$this->icon('heroicon-o-pencil');

$this->slideOver();

$this->modalHeading('Edit Discount');

$this->modalSubmitActionLabel('Edit Discount');

$this->modalFooterActionsAlignment(Alignment::End);

$this->successNotificationTitle('Discount updated successfully.');

$this->failureNotificationTitle('Something went wrong.');

$this->modalWidth(MaxWidth::Medium);

$this->fillForm(function (Model $record): array {
return $record->attributesToArray();
});

$this->action(function (Model $record, array $data) {
// action implementation
}

public function getForm(Forms\Form $form): ?Forms\Form
{
return DiscountForm::getFormFields($form);
}
}
I did browse through the source code and I found something regarding authorization in the CanBeHidden concern. However, I could not figure it out.
1 Reply
Butterfly
ButterflyOP8mo ago
If it's possible, I would also like to know how the prebuilt actions are able to automatically detect them
Want results from more Discord servers?
Add your server