Skip to content

gazduim/laravel-backpack-dropzone-field

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backpack Dropzone field

Add Dropzone support for < 4.0 Laravel Backpack.

This is a fork of Backpack Dropzone field that only adds support to the older versions.

Requirements

Limitations

Currently, you can only manage media while editing an entry.

Install

Via Composer

composer require gaspertrix/laravel-backpack-dropzone-field

Publish assets (without the install command):

php artisan vendor:publish --provider="Gaspertrix\Backpack\DropzoneField\DropzoneFieldServiceProvider" --tag="public"

Publish views (without the install command):

php artisan vendor:publish --provider="Gaspertrix\Backpack\DropzoneField\DropzoneFieldServiceProvider" --tag="views"

Usage

EntityCrudController

For simplicity add the HandleAjaxMedia trait to all EntityCrudController.

<?php

...

use Gaspertrix\Backpack\DropzoneField\Traits\HandleAjaxMedia;

...

class EntityCrudController extends CrudController
{
	...
    use HandleAjaxMedia;

	...
}

Routes

In your routes file, you have to add additionals routes.

<?php

...

Route::crud('entity', 'EntityCrudController')
Route::post('entity/{id}/media', 'EntityCrudController@uploadMedia');
Route::delete('entity/{id}/media/{mediaId}', 'EntityCrudController@deleteMedia');
Route::post('entity/{id}/media/reorder', 'EntityCrudController@reorderMedia');

...

Field

[
	...
	'type' => 'dropzone_media',
	'collection' => 'photos', // Media collection where files are added to
	'thumb_collection' => 'thumbs', // Media collection where thumb are displayed from. If not set, 'collection' is used by default
	'options' => [
		... // Dropzone options
	]
	...
]

Example:

<?php

...
$this->crud->operation(['update'], function() {
	$this->crud->addField([
		'label' => 'Photos',
		'type' => 'dropzone_media',
		'name' => 'photos',
		'collection' => 'photos',
		'thumb_collection' => 'thumbs',
		'options' => [
			'thumbnailHeight' => 120,
			'thumbnailWidth' => 120,
			'maxFilesize' => 10,
			'addRemoveLinks' => true,
			'createImageThumbnails' => true,
		],
	]);
});

...

Change log

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 adrian@gaspertrix.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Add Dropzone support for Laravel Backpack

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 67.6%
  • PHP 32.4%