From 386625edc1c0e6d4da84e8bafa72d5cbcc6f8ced Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Wed, 29 Apr 2020 23:38:51 +0200 Subject: [PATCH] [WIP] Add modules to shop --- app/Menu/Shop.php | 8 ++- app/Models/Shop/TagGroup.php | 11 ++++ app/Repositories/Shop/TagGroups.php | 54 +++++++++++++++++++ .../ArticleAttributeValues/create.blade.php | 14 ++--- .../ArticleAttributeValues/edit.blade.php | 12 ++--- .../Shop/Admin/ArticleAttributeFamilies.php | 4 ++ routes/Shop/Admin/route.php | 1 + 7 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 app/Models/Shop/TagGroup.php create mode 100644 app/Repositories/Shop/TagGroups.php create mode 100644 routes/Shop/Admin/ArticleAttributeFamilies.php diff --git a/app/Menu/Shop.php b/app/Menu/Shop.php index b4d872d0..f880f946 100644 --- a/app/Menu/Shop.php +++ b/app/Menu/Shop.php @@ -21,11 +21,15 @@ class Shop ->activeIfRoute(['Shop.Admin.Articles.*'])->order(2); $menu->addTo('shop', 'Familles d\'articles', [ 'route' => 'Shop.Admin.ArticleFamilies.index', 'permission' => 'backend_access' ]) ->activeIfRoute(['Shop.Admin.ArticleFamilies.*'])->order(3); + $menu->addTo('shop', 'Familles d\'attributs d\'articles', [ 'route' => 'Shop.Admin.ArticleAttributeFamilies.index', 'permission' => 'backend_access' ]) + ->activeIfRoute(['Shop.Admin.ArticleAttributeFamilies.*'])->order(4); + $menu->addTo('shop', 'Attributs d\'articles', [ 'route' => 'Shop.Admin.ArticleAttributes.index', 'permission' => 'backend_access' ]) + ->activeIfRoute(['Shop.Admin.ArticleAttributes.*'])->order(5); $menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Shop.Admin.Orders.*'])->order(4); + ->activeIfRoute(['Shop.Admin.Orders.*'])->order(6); $menu->addTo('shop', 'Factures', [ 'route' => 'Shop.Admin.Invoices.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Shop.Admin.Invoices.*'])->order(5); + ->activeIfRoute(['Shop.Admin.Invoices.*'])->order(7); } } diff --git a/app/Models/Shop/TagGroup.php b/app/Models/Shop/TagGroup.php new file mode 100644 index 00000000..a1b2257b --- /dev/null +++ b/app/Models/Shop/TagGroup.php @@ -0,0 +1,11 @@ +make(true); + } + + public static function getAll() + { + return TagGroup::orderBy('name','asc')->get(); + } + + public static function get($id) + { + return TagGroup::find($id); + } + + public static function store($data) + { + $id = isset($data['id']) ? $data['id'] : false; + $item = $id ? self::update($data) : self::create($data); + return $item->id; + } + + public static function create($data) + { + return TagGroup::create($data); + } + + public static function update($data) + { + return TagGroup::find($id)->update($data); + } + + public static function destroy($id) + { + return TagGroup::destroy($id); + } + +} diff --git a/resources/views/Shop/Admin/ArticleAttributeValues/create.blade.php b/resources/views/Shop/Admin/ArticleAttributeValues/create.blade.php index 53d5e646..95ecc6e6 100644 --- a/resources/views/Shop/Admin/ArticleAttributeValues/create.blade.php +++ b/resources/views/Shop/Admin/ArticleAttributeValues/create.blade.php @@ -1,19 +1,19 @@ @extends('layout.index', [ - 'title' => __('article_families.title'), - 'subtitle' => __('article_families.create.title'), - 'breadcrumb' => [__('article_families.title'), __('article_families.create.title')] + 'title' => __('article_attributes.title'), + 'subtitle' => __('article_attributes.create.title'), + 'breadcrumb' => [__('article_attributes.title'), __('article_attributes.create.title')] ]) @include('boilerplate::load.fileinput') @section('content') - {{ Form::open(['route' => 'Shop.Admin.ArticleFamilies.store', 'id' => 'article-family-form', 'autocomplete' => 'off', 'files' => true]) }} + {{ Form::open(['route' => 'Shop.Admin.ArticleAttributes.store', 'id' => 'article-attribute-form', 'autocomplete' => 'off', 'files' => true]) }}
- @include('Shop.Admin.ArticleFamilies.form') + @include('Shop.Admin.ArticleAttributes.form') @endsection diff --git a/resources/views/Shop/Admin/ArticleAttributeValues/edit.blade.php b/resources/views/Shop/Admin/ArticleAttributeValues/edit.blade.php index ab132b06..b7ac35b9 100644 --- a/resources/views/Shop/Admin/ArticleAttributeValues/edit.blade.php +++ b/resources/views/Shop/Admin/ArticleAttributeValues/edit.blade.php @@ -1,6 +1,6 @@ @extends('layout.index', [ - 'title' => 'Famille d\'articles', - 'subtitle' => 'Edition d\'une famille d\'article', + 'title' => 'Attributs d\'articles', + 'subtitle' => 'Edition d\'un attribut d\'article', 'breadcrumb' => ['Articles'] ]) @@ -8,12 +8,12 @@ @section('content') - {{ Form::open(['route' => 'Shop.Admin.ArticleFamilies.update', 'id' => 'article-family-form', 'autocomplete' => 'off', 'files' => true]) }} + {{ Form::open(['route' => 'Shop.Admin.ArticleAttributes.update', 'id' => 'article-attribute-form', 'autocomplete' => 'off', 'files' => true]) }}
- @include('Shop.Admin.ArticleFamilies.form') + @include('Shop.Admin.ArticleAttributes.form') @endsection diff --git a/routes/Shop/Admin/ArticleAttributeFamilies.php b/routes/Shop/Admin/ArticleAttributeFamilies.php new file mode 100644 index 00000000..c8431639 --- /dev/null +++ b/routes/Shop/Admin/ArticleAttributeFamilies.php @@ -0,0 +1,4 @@ +prefix('Admin')->namespace('Admin')->name('Admin.')->group(function () { Route::get('dashboard', 'DashboardController@index')->name('dashboard'); + include( __DIR__ . '/ArticleAttributeFamilies.php'); include( __DIR__ . '/ArticleAttributes.php'); include( __DIR__ . '/ArticleFamilies.php'); include( __DIR__ . '/ArticlePrices.php');