How do I Determine What Action is Called?

Apologies if this is covered in the filament docs, however, i couldn't find anything based on this issue. I have the following in my AuthorResource: ``` Forms\Components\TextInput::make('email') ->label('Email') ->required() ->email() ->columnSpan(['sm' => 2]) ->unique(modifyRuleUsing: function (Unique $rule) { return $rule->where('is_published', 1); }), and this in the EditAuthor: Action::make('save') ->action('save') ->label(fn (EditRecord $livewire) => $livewire->getRecord()->isPublished() ? __('filament-panels::resources/pages/edit-record.form.actions.save.label') : 'Publish') ->icon(fn (EditRecord $livewire) => $livewire->getRecord()->isPublished() ? 'heroicon-o-check-circle' : 'heroicon-o-eye'), how can i check that if the action "save" is called, then I should apply the ->unique rule that I have set, and if anything other than action "save" don't apply the unique rule.
Solution:
I've found an alternative solution. I've done this: ``` ->rules([ function () {...
Jump to solution
1 Reply
Solution
nathan269_
nathan269_14mo ago
I've found an alternative solution. I've done this:
->rules([
function () {
return function (string $attribute, $value, Closure $fail) {
// dd(request()->components[0]['calls'][0]['method']);
if (request()->components[0]['calls'][0]['method'] == 'save') {
//
} else if (request()->components[0]['calls'][0]['method'] == 'mountAction') {
// //
}
};
}
]),
->rules([
function () {
return function (string $attribute, $value, Closure $fail) {
// dd(request()->components[0]['calls'][0]['method']);
if (request()->components[0]['calls'][0]['method'] == 'save') {
//
} else if (request()->components[0]['calls'][0]['method'] == 'mountAction') {
// //
}
};
}
]),
Want results from more Discord servers?
Add your server