diff --git a/app/Datatables/Shop/ArticlesDataTable.php b/app/Datatables/Shop/ArticlesDataTable.php index f257a4e2..82fdff43 100644 --- a/app/Datatables/Shop/ArticlesDataTable.php +++ b/app/Datatables/Shop/ArticlesDataTable.php @@ -15,9 +15,16 @@ class ArticlesDataTable extends DataTable // $model = $model::with('Family')->select('shop_articles.*','family.name as family_name')->join('shop_article_families as family', 'family.id', '=', 'shop_articles.article_family_id')->groupBy('shop_articles.id'); $model = $model::with('article_nature')->select('shop_articles.*'); // $model = $model::joinRelations('Family')->select('shop_articles.*','shop_article_families.name as family_name'); + $model = self::filterByArticleNature($model); return self::buildQuery($model); } + public static function filterByArticleNature($model, $article_nature_id = false) + { + $article_nature_id = $article_nature_id ? $article_nature_id : self::isFilteredByField('article_nature_id'); + return $article_nature_id ? $model->byArticleNature($article_nature_id) : $model; + } + protected function getColumns() { return [ diff --git a/app/Datatables/Shop/TagsDataTable.php b/app/Datatables/Shop/TagsDataTable.php index 48326937..9976c1ba 100644 --- a/app/Datatables/Shop/TagsDataTable.php +++ b/app/Datatables/Shop/TagsDataTable.php @@ -21,7 +21,6 @@ class TagsDataTable extends DataTable { return [ Column::make('group.name')->title('Groupe'), - Column::make('sort_order')->title('Ordre'), Column::make('name')->title('Nom'), self::makeColumnButtons(), ]; diff --git a/app/Http/Controllers/Admin/Shop/ArticleController.php b/app/Http/Controllers/Admin/Shop/ArticleController.php index 8c35f446..1307a49f 100644 --- a/app/Http/Controllers/Admin/Shop/ArticleController.php +++ b/app/Http/Controllers/Admin/Shop/ArticleController.php @@ -18,7 +18,7 @@ class ArticleController extends Controller public function index(ArticlesDataTable $dataTable) { - $data['families'] = ArticleNatures::getOptions(); + $data['article_natures'] = ArticleNatures::getOptions(); return $dataTable->render('Admin.Shop.Articles.list', $data); } @@ -44,8 +44,7 @@ class ArticleController extends Controller public function edit($id) { - $data = Articles::getMeta(); - $data['article'] = Articles::getFull($id); + $data = Articles::getFull($id); return view('Admin.Shop.Articles.edit', $data); } diff --git a/app/Models/Shop/Article.php b/app/Models/Shop/Article.php index 0d703678..29082561 100644 --- a/app/Models/Shop/Article.php +++ b/app/Models/Shop/Article.php @@ -61,16 +61,26 @@ class Article extends Model implements HasMedia public function scopeByArticle($query, $id) { - return $query->where('shop_articles.id', $id); + return $query->where($this->table . '.id', $id); } public function scopeByCategory($query, $category_id) { } - public function scopeByFamily($query, $id) + public function scopeByArticleNature($query, $id) { - return $query->where('shop_articles.article_family_id', $id); + return $query->where($this->table . '.article_nature_id', $id); + } + + public function scopeByProduct($query, $model) + { + return $query->where($this->table . '.product_type', $model); + } + + public function scopeByProductId($query, $model_id) + { + return $query->where($this->table . '.product_id', $model_id); } public function registerMediaConversions(Media $media = null) : void diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php index 70ca65f7..83a37678 100644 --- a/app/Repositories/Shop/Articles.php +++ b/app/Repositories/Shop/Articles.php @@ -46,7 +46,7 @@ class Articles public static function getFull($id) { - $data = self::getArticleEdit($id); + $data['article'] = self::getArticleEdit($id); self::getMeta($data); return $data; } diff --git a/resources/lang/fr/shop.php b/resources/lang/fr/shop.php index a569f85f..7e0ac8f0 100644 --- a/resources/lang/fr/shop.php +++ b/resources/lang/fr/shop.php @@ -173,10 +173,10 @@ return [ 'title' => 'Unités', 'name' => 'Unité', 'description' => 'Gérer les unités', - 'add' => 'Ajouter une unités', - 'edit' => 'Editer une unités', - 'del' => 'Effacer une unités', - 'list' => 'Liste des unitéss', + 'add' => 'Ajouter une unité', + 'edit' => 'Editer une unité', + 'del' => 'Effacer une unité', + 'list' => 'Liste des unités', 'successadd' => 'L\'unité a été correctement ajoutée', 'successmod' => 'L\'unité a été correctement modifiée', 'successdel' => 'L\'unité a été correctement effacée', diff --git a/resources/views/Admin/Shop/ArticleNatures/create.blade.php b/resources/views/Admin/Shop/ArticleNatures/create.blade.php index 2d7c732b..6bfaa2af 100644 --- a/resources/views/Admin/Shop/ArticleNatures/create.blade.php +++ b/resources/views/Admin/Shop/ArticleNatures/create.blade.php @@ -1,7 +1,7 @@ @extends('layout.index', [ - 'title' => __('article_natures.title'), - 'subtitle' => __('article_natures.add'), - 'breadcrumb' => [__('article_natures.title'), __('article_natures.add')] + 'title' => __('shop.article_natures.title'), + 'subtitle' => __('shop.article_natures.add'), + 'breadcrumb' => [__('shop.article_natures.title'), __('shop.article_natures.add')] ]) @include('boilerplate::load.fileinput') diff --git a/resources/views/Admin/Shop/ArticleNatures/edit.blade.php b/resources/views/Admin/Shop/ArticleNatures/edit.blade.php index 131795dc..4cb152db 100644 --- a/resources/views/Admin/Shop/ArticleNatures/edit.blade.php +++ b/resources/views/Admin/Shop/ArticleNatures/edit.blade.php @@ -1,7 +1,7 @@ @extends('layout.index', [ - 'title' => __('article_natures.title'), - 'subtitle' => __('article_natures.edit'), - 'breadcrumb' => [__('article_natures.title'), __('article_natures.edit')] + 'title' => __('shop.article_natures.title'), + 'subtitle' => __('shop.article_natures.edit'), + 'breadcrumb' => [__('shop.article_natures.title'), __('shop.article_natures.edit')] ]) @include('boilerplate::load.fileinput') diff --git a/resources/views/Admin/Shop/Articles/list.blade.php b/resources/views/Admin/Shop/Articles/list.blade.php index fa2f6a1e..d9275c16 100644 --- a/resources/views/Admin/Shop/Articles/list.blade.php +++ b/resources/views/Admin/Shop/Articles/list.blade.php @@ -4,6 +4,8 @@ 'breadcrumb' => [__('shop.articles.title')] ]) +@include('load.form.select2') + @section('content') @include('components.datatable', ['route' => route('Admin.Shop.Articles.index'), 'model' => 'articles', 'with_filters' => true]) diff --git a/resources/views/Admin/Shop/Articles/partials/filters.blade.php b/resources/views/Admin/Shop/Articles/partials/filters.blade.php index 13d2310d..fb62bc8a 100644 --- a/resources/views/Admin/Shop/Articles/partials/filters.blade.php +++ b/resources/views/Admin/Shop/Articles/partials/filters.blade.php @@ -1,8 +1,8 @@
diff --git a/resources/views/Admin/Shop/Tags/create.blade.php b/resources/views/Admin/Shop/Tags/create.blade.php index e089ba26..1ca739f2 100644 --- a/resources/views/Admin/Shop/Tags/create.blade.php +++ b/resources/views/Admin/Shop/Tags/create.blade.php @@ -1,25 +1,12 @@ @extends('layout.index', [ - 'title' => __('tags.title'), - 'subtitle' => __('tags.create.title'), - 'breadcrumb' => [__('tags.title'), __('tags.create.title')] + 'title' => __('shop.tags.add'), + 'subtitle' => __('shop.tags.title'), + 'breadcrumb' => [__('shop.tags.title'), __('shop.tags.create')] ]) @section('content') {{ Form::open(['route' => 'Admin.Shop.Tags.store', 'id' => 'tag-form', 'autocomplete' => 'off']) }} - -