From 0bc8cd19c7ccb9e24eb13b3f3a2df29872386f5b Mon Sep 17 00:00:00 2001 From: Carlos Tamagawa Date: Fri, 26 May 2017 19:38:20 +0000 Subject: [PATCH] Fix --- src/Category.php | 29 ++---------------------- src/config/mcategories.php | 16 ------------- src/resources/views/admin/form.blade.php | 10 -------- 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/src/Category.php b/src/Category.php index 3cfef56..6723ac3 100755 --- a/src/Category.php +++ b/src/Category.php @@ -21,7 +21,7 @@ class Category extends Model protected $dates = ['deleted_at']; - protected $fillable = ['status', 'name', 'description', 'image', 'type']; + protected $fillable = ['status', 'name', 'description', 'type']; public $translatable = ['name', 'description', 'slug']; @@ -36,39 +36,14 @@ public function sluggable() public function __construct(array $attributes = []) { - $this->hasAttachedFile('image', [ - 'styles' => [ - 'crop' => function ($file, $imagine) { - $image = $imagine->open($file->getRealPath()); - if (request()->input('crop.image.w', 0) > 0 && request()->input('crop.image.y', 0) > 0) { - $image->crop(new \Imagine\Image\Point(request()->input('crop.image.x'), request()->input('crop.image.y')) - , new \Imagine\Image\Box(request()->input('crop.image.w'), request()->input('crop.image.h'))); - } - return $image; - } - ], - /*'default_url' => '/assets/img/avatar.png',*/ - ]); - - parent::__construct($attributes); + parent::__construct($attributes); } public static function boot() { parent::boot(); - - static::bootStapler(); } - public function toArray() - { - return array_merge(parent::toArray(), [ - 'image' => $this->attachedFiles['image']->url() - , 'image_crop' => $this->attachedFiles['image']->url('crop') - ]); - } - - public function scopeSort($query, $fields = []) { if (count($fields) <= 0) { diff --git a/src/config/mcategories.php b/src/config/mcategories.php index 99ac7e8..fda83be 100644 --- a/src/config/mcategories.php +++ b/src/config/mcategories.php @@ -4,20 +4,4 @@ 'name' => 'Categorias' , 'icon' => 'fa fa-align-left' , 'order' => 50 - - /* - para desabilitar a imagem passe false como valor - , 'image' => false - - para habilitar a imagem passe o array com o width e height - , 'image' => [ - 'width' => 640 - , 'height' => 480 - ] - */ - , 'image' => [ - 'width' => 640 - , 'height' => 480 - ] - ]; \ No newline at end of file diff --git a/src/resources/views/admin/form.blade.php b/src/resources/views/admin/form.blade.php index aefc794..bc626b5 100755 --- a/src/resources/views/admin/form.blade.php +++ b/src/resources/views/admin/form.blade.php @@ -29,16 +29,6 @@ {!! BootForm::text('name', 'Nome', null, ['data-rule-required' => true, 'maxlength' => '150']) !!} - @if (config('mcategories.image', true)) - {!! BootForm::file('image', 'Imagem', [ - 'data-allowed-file-extensions' => '["jpg", "png"]', - 'data-initial-preview' => '["image->url('crop') . '\" class=\"file-preview-image\">"]', - 'data-initial-caption' => $category->image->originalFilename(), - 'data-min-image-width' => config('mcategories.image.width', 640), - 'data-min-image-height' => config('mcategories.image.height', 480), - 'data-aspect-ratio' => number_format(config('mcategories.image.width', 640)/config('mcategories.image.height', 480), 2) - ]) !!} - @endif