A Laravel Nova field for laravel-medilibrary.
php: >=8.0
laravel/nova: ^4.0
spatie/laravel-medilibrary
: ^11.4# Install the package
composer require stepanenko3/nova-media-field
use use Stepanenko3\NovaMediaField\Fields\Media;
...
Media::make(__('Image'), 'image'), // Single image. Auto detect from collection
Media::make(__('Images'), 'images'), // Multiple images. Auto detect from collection
// Validation rules
Media::make('Images', 'images')
->rules(['required', 'array', 'max:4'])
->singleMediaRules(['image', 'max:80']),
// Custom properties with validtion
Media::make('Images', 'images')
->customPropertiesFields([
Boolean::make('Active', 'active')
->rules(['boolean']),
Markdown::make('Description', 'description')
->rules(['max:1000']),
])
// Count images displayed on index
Media::make('Images', 'images')
->countOfImagesDisplayedOnIndex(2),
// Full example
Media::make('Images', 'images')
->customPropertiesFields([
Boolean::make('Active', 'active')
->rules(['boolean']),
Markdown::make('Description', 'description')
->rules(['max:1000']),
])
->countOfImagesDisplayedOnIndex(2)
->rules(['required', 'array', 'max:4'])
->singleMediaRules(['image', 'max:80']),
compore require stepanenko3/nova-filemanager
// app/Providers/NovaServiceProvider.php
public function tools(): array
{
return [
new Stepanenko3\NovaFileManager\FileManagerTool,
];
}
Media::make(__('Image'), 'image')
->fileManager(),
Thank you for considering contributing to this package! Please create a pull request with your contributions with detailed explanation of the changes you are proposing.
This package is open-sourced software licensed under the MIT license.