label(__('filament.actions.models.wiki.upload_image.name')); $this->facets([ ImageFacet::GRILL, ImageFacet::DOCUMENT, ]); $this->authorize('create', Image::class); } /** * Perform the action on the table. * * @param array $fields * @return void */ public function handle(array $fields): void { $action = new UploadImageAction(); $action->handle($fields); } /** * Get the fields available on the action. * * @param Form $form * @return Form */ public function getForm(Form $form): Form { $options = []; foreach ($this->facets as $facet) { $options[$facet->value] = $facet->localize(); } return $form ->schema([ Select::make(Image::ATTRIBUTE_FACET) ->label(__('filament.fields.image.facet.name')) ->helperText(__('filament.fields.image.facet.help')) ->options($options) ->required() ->rules(['required', new Enum(ImageFacet::class)]), FileUpload::make(Image::ATTRIBUTE_PATH) ->label(__('filament.fields.image.image.name')) ->required() ->image() ->imageEditor() ->imageEditorAspectRatios([null, '2:3']) ->storeFiles(false), ]) ->columns(1); } /** * Get the facets available for the action. * * @param ImageFacet[] $facets * @return static */ public function facets(array $facets): static { $this->facets = $facets; return $this; } }