label(__('filament.actions.video.backfill.name')); $this->modalWidth(MaxWidth::TwoExtraLarge); $this->authorize('create', Audio::class); $this->action(fn (Video $record, array $data) => $this->handle($record, $data)); } /** * Perform the action on the given models. * * @param Video $video * @param array $data * @return void */ public function handle(Video $video, array $data): void { $deriveSourceVideo = DeriveSourceVideo::from(intval(Arr::get($data, self::DERIVE_SOURCE_VIDEO))); $overwriteAudio = OverwriteAudio::from(intval(Arr::get($data, self::OVERWRITE_AUDIO))); $action = new BackfillAudio($video, $deriveSourceVideo, $overwriteAudio); try { $result = $action->handle(); if ($result->hasFailed()) { Notification::make() ->body($result->getMessage()) ->warning() ->actions([ NotificationAction::make('mark-as-read') ->button() ->markAsRead(), ]) ->sendToDatabase(Auth::user()); } } catch (Exception $e) { $this->failedLog($e); } } /** * Get the fields available on the action. * * @param Form $form * @return Form * * @noinspection PhpMissingParentCallCommonInspection */ public function getForm(Form $form): Form { return $form ->schema([ Select::make(self::DERIVE_SOURCE_VIDEO) ->label(__('filament.actions.video.backfill.fields.derive_source.name')) ->options(DeriveSourceVideo::asSelectArray()) ->rules(['required', new Enum(DeriveSourceVideo::class)]) ->default(DeriveSourceVideo::YES->value) ->helperText(__('filament.actions.video.backfill.fields.derive_source.help')), Select::make(self::OVERWRITE_AUDIO) ->label(__('filament.actions.video.backfill.fields.overwrite.name')) ->options(OverwriteAudio::asSelectArray()) ->rules(['required', new Enum(OverwriteAudio::class)]) ->default(OverwriteAudio::NO->value) ->helperText(__('filament.actions.video.backfill.fields.overwrite.help')), ]); } }