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
No description
Save the model, undoing the uploader's change if that fails, including when a `saving` or `updating` listener cancels it by returning false.
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:
Details
at
line 52
static array
endpoints(string $ability = 'edit', string $validator = IconImageValidator::class)
at
line 113
static protected IconImageUploader
uploader( AbstractModel $model)
The model's uploader: HasIconImage::iconImageUploader().
at
line 124
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.
at
line 149
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(...))