Butterfly
Butterfly
FFilament
Created by Butterfly on 4/2/2024 in #❓┊help
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.
3 replies
FFilament
Created by Butterfly on 3/11/2024 in #❓┊help
Passing props to a custom column
I have the following custom column
@props(['title', 'subtitle'])

<div>
<div class="flex items-center">
<div class="ml-2.5 truncate flex flex-col text-left">
<div class="text-sm font-medium truncate text-foreground">
{{ $title }}
</div>

<div class="text-xs truncate text-muted-foreground">
{{ $subtitle }}
</div>
</div>
</div>
</div>
@props(['title', 'subtitle'])

<div>
<div class="flex items-center">
<div class="ml-2.5 truncate flex flex-col text-left">
<div class="text-sm font-medium truncate text-foreground">
{{ $title }}
</div>

<div class="text-xs truncate text-muted-foreground">
{{ $subtitle }}
</div>
</div>
</div>
</div>
Is there a way to pass the props from the resource?
MediaObjectColumn::make('avatar_url')
->label('Avatar')

MediaObjectColumn::make('avatar_url')
->label('Avatar')

10 replies