From f3b6504723155c80133a972c15be28a044355e7d Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Sun, 7 Nov 2021 17:16:35 +0100 Subject: [PATCH] Fixes --- app/Datatables/Botanic/SpeciesDataTable.php | 16 +++++++++++++--- app/Datatables/ParentDataTable.php | 3 +-- app/Menu/Shop.php | 3 +++ app/Models/Shop/Tag.php | 9 ++++----- app/Repositories/Shop/Tags.php | 11 ++++------- .../views/Admin/Botanic/Species/create.blade.php | 2 -- .../views/Admin/Botanic/Species/edit.blade.php | 4 +--- .../views/Admin/Botanic/Species/form.blade.php | 8 +------- .../uploader/mini-gallery-items.blade.php | 2 +- .../views/components/uploader/widget.blade.php | 4 +++- resources/views/load/form/select2.blade.php | 14 ++++++++++---- 11 files changed, 41 insertions(+), 35 deletions(-) diff --git a/app/Datatables/Botanic/SpeciesDataTable.php b/app/Datatables/Botanic/SpeciesDataTable.php index 0412d11a..ac0a0c23 100644 --- a/app/Datatables/Botanic/SpeciesDataTable.php +++ b/app/Datatables/Botanic/SpeciesDataTable.php @@ -13,7 +13,7 @@ class SpeciesDataTable extends DataTable public function query(Specie $model) { - $model = $model::withCount('varieties')->with(['genre','image']); + $model = $model::withCount(['images','varieties','tags'])->with(['genre','image','tags']); return $this->buildQuery($model); } @@ -26,7 +26,14 @@ class SpeciesDataTable extends DataTable ->editColumn('genre_name', function (Specie $specie) { return $specie->genre ? $specie->genre->name : ''; }) - ->rawColumns(['thumb', 'genre_name', 'action']); + ->editColumn('tags2', function (Specie $specie) { + $html = ''; + foreach ($specie->tags as $tag) { + $html .= '' . $tag->slug . ' '; + } + return $html; + }) + ->rawColumns(['thumb', 'tags2', 'genre_name', 'action']); return parent::modifier($datatables); } @@ -38,7 +45,10 @@ class SpeciesDataTable extends DataTable Column::make('alias'), Column::make('genre.name')->data('genre_name')->title('Genre'), Column::make('latin'), - Column::make('varieties_count')->title('Nb variétés')->searchable(false)->addClass('text-right'), + Column::make('tags2')->title('Tags')->searchable(false)->orderable(false), + Column::make('varieties_count')->title('#Var')->searchable(false)->addClass('text-right'), + Column::make('tags_count')->title('#Tag')->searchable(false)->addClass('text-right'), + Column::make('images_count')->title('#Pho')->searchable(false)->addClass('text-right'), $this->makeColumnButtons(), ]; } diff --git a/app/Datatables/ParentDataTable.php b/app/Datatables/ParentDataTable.php index a3424e9b..ca6ae377 100644 --- a/app/Datatables/ParentDataTable.php +++ b/app/Datatables/ParentDataTable.php @@ -97,7 +97,6 @@ class ParentDataTable extends DataTable */ public function buildQuery($model) { - // $model = $model->select($model->getTable() . '.*'); return $model->newQuery(); } @@ -150,7 +149,7 @@ class ParentDataTable extends DataTable 'colReorder' => $this->colReorder, 'fixedColumns' => $this->fixedColumns, 'fixedHeader' => $this->fixedHeader, - 'pageLength' => 5, + 'pageLength' => 10, 'searchDelay' => 500, 'scrollX' => $this->scrollX, 'scrollCollapse' => $this->scrollCollapse, diff --git a/app/Menu/Shop.php b/app/Menu/Shop.php index 4b6c67f2..f3e6a19e 100644 --- a/app/Menu/Shop.php +++ b/app/Menu/Shop.php @@ -28,6 +28,9 @@ class Shop $menu->addTo('shop', 'Tags', [ 'route' => 'Admin.Shop.Tags.index', 'permission' => 'backend_access' ]) ->activeIfRoute(['Admin.Shop.Tags.*'])->order(8); + $menu->addTo('shop', 'Groupes de tags', [ 'route' => 'Admin.Shop.TagGroups.index', 'permission' => 'backend_access' ]) + ->activeIfRoute(['Admin.Shop.TagGroups.*'])->order(8); + $menu->addTo('shop', 'Natures d\'articles', [ 'route' => 'Admin.Shop.ArticleNatures.index', 'permission' => 'backend_access' ]) ->activeIfRoute(['Admin.Shop.ArticleNatures.*'])->order(9); diff --git a/app/Models/Shop/Tag.php b/app/Models/Shop/Tag.php index 857abc90..0f4fe11d 100644 --- a/app/Models/Shop/Tag.php +++ b/app/Models/Shop/Tag.php @@ -4,8 +4,12 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Spatie\Translatable\HasTranslations; + class Tag extends Model { + use HasTranslations; + protected $guarded = ['id']; public $translatable = ['name']; @@ -40,9 +44,4 @@ class Tag extends Model { return $query->where($this->table . '.tag_group_id', $id); } - - public function getNameAttribute($value) - { - return json_decode($value)->fr ?? false; - } } diff --git a/app/Repositories/Shop/Tags.php b/app/Repositories/Shop/Tags.php index 75849f81..ffc93c23 100644 --- a/app/Repositories/Shop/Tags.php +++ b/app/Repositories/Shop/Tags.php @@ -49,13 +49,10 @@ class Tags public static function create($data) { - $slug = self::buildSlug($data); - $tag = app('rinvex.tags.tag')->create([ - 'name' => ['fr' => $data['name']], - 'slug' => $slug, - 'tag_group_id' => $data['tag_group_id'], - 'sort_order' => self::getNewOrder($data['tag_group_id']) - ]); + $data['name'] = ['fr' => $data['name']]; + $data['slug'] = self::buildSlug($data); + $data['sort_order'] = self::getNewOrder($data['tag_group_id']); + $tag = Tag::create($data); return $tag; } diff --git a/resources/views/Admin/Botanic/Species/create.blade.php b/resources/views/Admin/Botanic/Species/create.blade.php index 2528a538..33eb0e84 100644 --- a/resources/views/Admin/Botanic/Species/create.blade.php +++ b/resources/views/Admin/Botanic/Species/create.blade.php @@ -5,9 +5,7 @@ ]) @section('content') - {{ Form::open(['route' => 'Admin.Botanic.Species.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }} @include('Admin.Botanic.Species.form') - @endsection diff --git a/resources/views/Admin/Botanic/Species/edit.blade.php b/resources/views/Admin/Botanic/Species/edit.blade.php index d67fe89b..d82bf181 100644 --- a/resources/views/Admin/Botanic/Species/edit.blade.php +++ b/resources/views/Admin/Botanic/Species/edit.blade.php @@ -5,10 +5,8 @@ ]) @section('content') - {{ Form::open(['route' => 'Admin.Botanic.Species.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }} - + @include('Admin.Botanic.Species.form') - @endsection diff --git a/resources/views/Admin/Botanic/Species/form.blade.php b/resources/views/Admin/Botanic/Species/form.blade.php index 4b1a74fd..a322ef0e 100644 --- a/resources/views/Admin/Botanic/Species/form.blade.php +++ b/resources/views/Admin/Botanic/Species/form.blade.php @@ -1,7 +1,3 @@ -@include('boilerplate::load.fileinput') -@include('boilerplate::load.select2') -@include('boilerplate::load.tinymce') -
@@ -43,7 +39,7 @@
- @include('components.uploader.widget', ['load_url' => route('Admin.Botanic.Species.getImages', ['id' => $specie['id'] ?? false]), 'delete_url' => route('Admin.Botanic.Species.deleteImage'), 'name' => 'images']) + @include('components.uploader.widget', ['load_url' => ($specie['id'] ?? false) ? route('Admin.Botanic.Species.getImages', ['id' => $specie['id']]) : null, 'delete_url' => route('Admin.Botanic.Species.deleteImage'), 'name' => 'images'])
@@ -53,9 +49,7 @@ @include('load.form.editor') @include('load.form.save') @include('load.form.select2') - @include('load.form.upload.fileinput') -@include('boilerplate::load.tinymce') @push('js') @if ($no_popup ?? true) diff --git a/resources/views/load/form/select2.blade.php b/resources/views/load/form/select2.blade.php index 9a3898c1..e8b46201 100644 --- a/resources/views/load/form/select2.blade.php +++ b/resources/views/load/form/select2.blade.php @@ -1,7 +1,7 @@ @if(!defined('LOAD_SELECT2')) @push('scripts') - + @endpush