kavela / enhanced-image-uploader
Repeatable image field for Laravel Nova applications
Requires
- php: >=7.2
- ext-json: *
- intervention/image: ^2.5
- laravel/nova: ^3.0
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ^5.0|^6.0
- phpunit/phpunit: ^8.0|^9.0
README
This package contains a Nova field to add images to resources.
Requirements
This Nova field requires PHP 7.2 or higher.
Installation
You can install this package into a Laravel app that uses Nova via composer:
composer require kavela/enhanced-image-uploader
php artisan enhanced-image-uploader:install
php artisan migrate
Usage
To make an Eloquent model imageable follow next steps:
Update config/enhanced-image-uploader.php
configuration file.
Next add the Kavela\EnhancedImageUploader\Traits\HasImages
trait to it:
class Project extends Model { use Kavela\EnhancedImageUploader\Traits\HasImages; ... }
Next you can use the Kavela\EnhancedImageUploader\Images
field in your Nova resource:
namespace App\Nova; use Kavela\EnhancedImageUploader\Images; class Project extends Resource { // ... public function fields(Request $request) { return [ // ... Images::make('Images'), // ... ]; } }
All images will be saved in the enhanced_image_uploader_images
table.
Limiting images
You can limit the number of images with limit()
.
Images::make('Images')->limit($maxNumber),
Processing method (fit, resize, crop, etc.) of images
Images::make('Images')->method('fit'),
Constraints (aspectRatio, upsize, etc.) for the images processing method
Images::make('Images')->constraints([ 'aspectRatio', 'upsize' ]),
Images quality
Images::make('Images')->quality(60),
Saved images format
Images::make('Images')->format('jpg'),
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email dev.kavelashvili@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.