class IconImageApi

The API surface of an icon image, for a resource whose model uses HasIconImage. Add the endpoints and fields to the resource:

public function endpoints(): array { return [...IconImageApi::endpoints(), ...]; } `POST /{type}/{id}/icon-image` takes the file as the `iconImage` form field, `DELETE /{type}/{id}/icon-image` clears it. Both return the resource. They save the model directly, not through the resource's saving hooks, and dispatch Event\IconImageSaving before the change and Event\IconImageChanged after it instead. The model's iconImageUploader() stores the image. The endpoints are named `iconImage.upload` and `iconImage.delete`, so an extension can alter them with the ApiResource extender.

Methods

static array
endpoints(string $ability = 'edit', string $validator = IconImageValidator::class)

No description

uploader( AbstractModel $model)

The model's uploader: HasIconImage::iconImageUploader().

static void
save( AbstractModel $model, IconImageUploader $uploader)

Save the model, undoing the uploader's change if that fails, including when a `saving` or `updating` listener cancels it by returning false.

static mixed
withoutImageClasses(mixed $icon)

Remove the classes the frontend adds to an icon to show its image (`IconImage`, `IconImage--<n>`), so a form that saves back the icon it was given stores only the Font Awesome classes. For the resource's icon field:

static array
fields()

No description

Details

static array endpoints(string $ability = 'edit', string $validator = IconImageValidator::class)

Parameters

string $ability The ability the actor needs on the model.
string $validator The validator for uploads.

Return Value

array

static protected IconImageUploader uploader( AbstractModel $model)

The model's uploader: HasIconImage::iconImageUploader().

Parameters

AbstractModel $model

Return Value

IconImageUploader

static protected void save( AbstractModel $model, IconImageUploader $uploader)

Save the model, undoing the uploader's change if that fails, including when a `saving` or `updating` listener cancels it by returning false.

Parameters

AbstractModel $model
IconImageUploader $uploader

Return Value

void

static mixed withoutImageClasses(mixed $icon)

Remove the classes the frontend adds to an icon to show its image (`IconImage`, `IconImage--<n>`), so a form that saves back the icon it was given stores only the Font Awesome classes. For the resource's icon field:

Schema\Str::make('icon')->deserialize(IconImageApi::withoutImageClasses(...))

Parameters

mixed $icon

Return Value

mixed

static array fields()

Return Value

array