Download the PHP package ardenthq/nova-image-gallery-field without Composer
On this page you can find all versions of the php package ardenthq/nova-image-gallery-field. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ardenthq/nova-image-gallery-field
More information about ardenthq/nova-image-gallery-field
Files in ardenthq/nova-image-gallery-field
Package nova-image-gallery-field
Short Description Field for Nova that allows you to upload multiple images and sort them
License MIT
Informations about the package nova-image-gallery-field
Laravel Nova Image Gallery Field
A custom Nova field that allows multiple image upload with sorting
Features
- For Laravel Nova ^4.0 and Nova ^5.0 when using the
nova5branch. - Multiple image upload into a
spatie/laravel-medialibrarycollection. - Image sorting
- Custom Image Validation
- Drag & Drop
- Dark Mode
Installation
For Nova 5 and Laravel 12 support:
For Nova 4 and Laravel 11 support:
Requirements
- PHP ^8.0
- Laravel
- Laravel nova ^5 when using the
nova5branch, otherwise Laravel Nova ^4.22. For lower versions see the Compatibility Branch - Laravel Media Library
Use
Note This package reuses part of the logic used on the
Laravel\Nova\Fields\TrixField to store and handle files. This means we need to follow some steps that are mentioned on the Laravel Nova docs related to adding the migrations and pruning the files.
- Define two database tables to store pending and persisted Trix uploads. To do so, create a migration with the following table definitions:
Note: latest nova already includes these migrations. If so, you might receive error Table already exists while running migrations. In this case, you might only need to add original_name field in nova_pending_field_attachments:
-
In your
app/Console/Kernel.phpfile, you should register a daily job to prune any stale attachments from the pending attachments table and storage. Laravel Nova provides the job implementation needed to accomplish this: -
Add the
ImageGalleryFieldfield to your Nova Resource. -
Consider that the images will be stored in a
Spatie\MediaLibrary\MediaCollections\Models\Mediacollection according to the name passed as the first parameter on the fieldmakemethod or the second parameter if set. (Dont forget to register a media collection in your model) -
Use the
rules()method to define the rules used for every single image. -
Use the
rulesMessages()method to define custom validation messages for the image rules. - Use the
help()method if you want to place "help" text inside the Drag & Drop area.
Example
Compatibility Branch
Due to changes made to the Trix fields in Nova 4.22, this package does not support lower Nova v4 versions on the main branch. If you want to use this package on an older Nova version, please see the nova-compatibility branch in this repostitory and use that to install the package through composer: composer require ardenthq/nova-image-gallery-field:dev-nova-compatibility
Development
- Run
yarn nova:installandyarn installto install all the necessary dependencies for compiling the view components. - Run
yarn run dev(oryarn run watch) while making changes to the components in your local environment. - If you change the vue components, ensure to compile for production before making a PR.
Compile for production
- Run
yarn nova:installandyarn installto install all the necessary dependencies for compiling the view components. - Run
yarn run production.
Analyze the code with phpstan
Refactor the code with php rector
Format the code with php-cs-fixer
Run tests
Security
If you discover a security vulnerability within this package, please send an e-mail to [email protected]. All security vulnerabilities will be promptly addressed.
Credits
This project exists thanks to all the people who contribute.
License
Ardent
All versions of nova-image-gallery-field with dependencies
laravel/framework Version ^8.0|^9.0|^10.0|^11.0
laravel/nova Version ^4.22
spatie/laravel-medialibrary Version ^10.5|^11.0