This package provides a Dropzone field for Laravel Backpack.
You can install the package via composer:
composer config repositories.laravel-backpack-dropzone vcs https://github.com/jargoud/laravel-backpack-dropzone.git
composer require jargoud/laravel-backpack-dropzone
Then, publish the package assets and config:
php artisan vendor:publish --provider="Jargoud\LaravelBackpackDropzone\Providers\LaravelBackpackDropzoneServiceProvider"
As this package relies on pionl/laravel-chunk-upload, you can publish its config:
php artisan vendor:publish --provider="Pion\Laravel\ChunkUpload\Providers\ChunkUploadServiceProvider"
In your Backpack CRUD controller, add a dropzone field:
CRUD::addField([
'name' => 'video',
'type' => 'dropzone',
'view_namespace' => 'dropzone::fields',
'allow_multiple' => false, // false if missing key
'config' => [
// any option from the Javascript library
'chunkSize' => 1024 * 1024 * 2, // for 2 MB
'chunking' => true,
],
]);
Library options can be found on Dropzone documentation.
In your request, to validate the input value, use our Dropzone rule:
use Jargoud\LaravelBackpackDropzone\Rules\Dropzone;
public function rules(): array {
return [
'video' => [
new Dropzone(['video/mp4']),
],
'photos' => [
'array',
],
'photos.*' => [
new Dropzone(['image/png'], [MyModel::find($this->id), "isPhotoFileExisting"]),
],
];
}
It works like Laravel's mimetypes
validation rule and needs an array of mime types.
Then, uploaded file is stored in storage/app/upload
. It can be handled through Laravel's filesystem:
\Storage::disk(config('chunk-upload.storage.disk'))->path($filePath);
composer test
Please see CHANGELOG for more information what has changed recently.
To compile assets, run the following commands:
npm install
npm run mix
It will generate CSS and JS files in resources directory.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email jeremy.argoud@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.