From 6f2a985edc5e994f9e620a89a8ccc48980bb9fcb Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Tue, 1 Aug 2023 21:55:17 +0200 Subject: [PATCH] fixes, add weight --- app/Datatables/Shop/OffersDataTable.php | 31 +-- .../Shop/Auth/RegisterController.php | 37 ++- app/Http/Requests/Shop/RegisterCustomer.php | 24 ++ resources/lang/fr/shop.php | 21 +- .../views/Admin/Shop/Offers/form.blade.php | 253 ++++++++++-------- .../views/Admin/Shop/Offers/list.blade.php | 39 +-- .../Shop/Offers/partials/filters.blade.php | 48 +++- .../Shop/Articles/partials/article.blade.php | 11 +- .../Customers/partials/registration.blade.php | 1 + .../Shop/auth/partials/register.blade.php | 8 +- .../views/components/form/toggle.blade.php | 2 + 11 files changed, 295 insertions(+), 180 deletions(-) create mode 100644 app/Http/Requests/Shop/RegisterCustomer.php diff --git a/app/Datatables/Shop/OffersDataTable.php b/app/Datatables/Shop/OffersDataTable.php index 155047ca..a9dfafad 100644 --- a/app/Datatables/Shop/OffersDataTable.php +++ b/app/Datatables/Shop/OffersDataTable.php @@ -22,18 +22,18 @@ class OffersDataTable extends DataTable return $this->buildQuery($model); } - public static function filterByArticleNature($model, $article_nature_id = false) + public static function filterByArticleNature($model, $articleNatureId = false) { - $article_nature_id = $article_nature_id ? $article_nature_id : self::isFilteredByField('article_nature_id'); + $articleNatureId = $articleNatureId ? $articleNatureId : self::isFilteredByField('article_nature_id'); - return $article_nature_id ? $model->byArticleNature($article_nature_id) : $model; + return $articleNatureId ? $model->byArticleNature($articleNatureId) : $model; } - public static function filterByPackage($model, $package_id = false) + public static function filterByPackage($model, $packageId = false) { - $package_id = $package_id ? $package_id : self::isFilteredByField('package_id'); + $packageId = $packageId ? $packageId : self::isFilteredByField('package_id'); - return $package_id ? $model->byPackage($package_id) : $model; + return $packageId ? $model->byPackage($packageId) : $model; } public function modifier($datatables) @@ -49,7 +49,7 @@ class OffersDataTable extends DataTable 'on' => __('active'), 'off' => __('inactive'), 'meta' => 'data-id='.$offer->id, - 'size' => 'sm', + 'size' => 'xs', ]); }) ->editColumn('stock_delayed', function (Offer $offer) { @@ -63,15 +63,16 @@ class OffersDataTable extends DataTable protected function getColumns() { return [ - Column::make('status_id')->title('')->width(40), - Column::make('article.article_nature.name')->title('Nature')->defaultContent(''), - Column::make('thumb')->title('')->width(40)->searchable(false)->order(false), + Column::make('status_id')->title('')->width(40)->searchable(false), + Column::make('article.article_nature.name')->title('Nature')->defaultContent('')->searchable(false), + Column::make('thumb')->title('')->width(30)->searchable(false)->addClass('text-center'), Column::make('article.name')->title('Article')->defaultContent(''), - Column::make('variation.name')->title('Déclinaison')->defaultContent(''), - Column::make('tariff.name')->title('Tarif')->defaultContent(''), - Column::make('stock_current')->title('Appro im')->searchable(false), - Column::make('stock_delayed')->title('Appro délai')->searchable(false), - Column::make('stock_ondemand')->title('Dmde')->searchable(false), + Column::make('variation.name')->title('Déclinaison')->defaultContent('')->searchable(false), + Column::make('weight')->title('Poids')->searchable(false)->addClass('text-right'), + Column::make('tariff.name')->title('Tarif')->defaultContent('')->searchable(false), + Column::make('stock_current')->title('Appro im')->searchable(false)->addClass('text-right'), + Column::make('stock_delayed')->title('Appro délai')->searchable(false)->addClass('text-right'), + Column::make('stock_ondemand')->title('Dmde')->searchable(false)->addClass('text-right'), $this->makeColumnButtons(), ]; } diff --git a/app/Http/Controllers/Shop/Auth/RegisterController.php b/app/Http/Controllers/Shop/Auth/RegisterController.php index d6d797d1..eda0c55c 100644 --- a/app/Http/Controllers/Shop/Auth/RegisterController.php +++ b/app/Http/Controllers/Shop/Auth/RegisterController.php @@ -3,18 +3,19 @@ namespace App\Http\Controllers\Shop\Auth; use App\Http\Controllers\Controller; +use App\Http\Requests\Shop\RegisterCustomer; use App\Repositories\Shop\CustomerAddresses; use App\Repositories\Shop\Customers; +use Illuminate\Auth\Events\Registered; use Illuminate\Foundation\Auth\EmailVerificationRequest; use Illuminate\Foundation\Auth\RegistersUsers; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Validator; -use Sebastienheyd\Boilerplate\Rules\Password; class RegisterController extends Controller { - use RegistersUsers; + // use RegistersUsers; protected $redirectTo; @@ -28,21 +29,31 @@ class RegisterController extends Controller return route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard')); } - protected function validator(array $data) - { - return Validator::make($data, [ - 'last_name' => 'required|max:255', - 'first_name' => 'required|max:255', - 'email' => 'required|email|max:255|unique:shop_customers,email,NULL,id,deleted_at,NULL', - 'password' => ['required', 'confirmed', new Password()], - ]); - } - public function showRegistrationForm() { return view('Shop.auth.register'); } + public function register(Request $request) + { + dump('ici'); + exit; + // event(new Registered($user = $this->create($request->all()))); + $user = $this->create($request->all()); + dump($user); + exit; + + $this->guard()->login($user); + + if ($response = $this->registered($request, $user)) { + return $response; + } + + return $request->wantsJson() + ? new JsonResponse([], 201) + : redirect($this->redirectPath()); + } + protected function create(array $data) { $user = Customers::create($data); diff --git a/app/Http/Requests/Shop/RegisterCustomer.php b/app/Http/Requests/Shop/RegisterCustomer.php new file mode 100644 index 00000000..d73e6c84 --- /dev/null +++ b/app/Http/Requests/Shop/RegisterCustomer.php @@ -0,0 +1,24 @@ + 'required|max:255', + 'first_name' => 'required|max:255', + 'email' => 'required|email|max:255|unique:shop_customers,email,NULL,id,deleted_at,NULL', + 'password' => ['required', 'confirmed', new Password()], + ]; + } +} diff --git a/resources/lang/fr/shop.php b/resources/lang/fr/shop.php index 56b226b7..b463762e 100644 --- a/resources/lang/fr/shop.php +++ b/resources/lang/fr/shop.php @@ -159,16 +159,17 @@ return [ 'confirmdelete' => 'Confirmez-vous la suppression de l\'offre ?', ], 'packages' => [ - 'title' => 'Packages', - 'description' => 'Gérer les packages', - 'add' => 'Ajouter un package', - 'edit' => 'Editer un package', - 'del' => 'Effacer un package', - 'list' => 'Liste des packages', - 'successadd' => 'Le package été correctement ajouté', - 'successmod' => 'Le package a été correctement modifié', - 'successdel' => 'Le package a été correctement effacé', - 'confirmdelete' => 'Confirmez-vous la suppression du package ?', + 'title' => 'Déclinaisons', + 'name' => 'Déclinaison', + 'description' => 'Gérer les déclinaisons', + 'add' => 'Ajouter une déclinaison', + 'edit' => 'Editer une déclinaison', + 'del' => 'Effacer une déclinaison', + 'list' => 'Liste des déclinaisons', + 'successadd' => 'La déclinaison été correctement ajoutée', + 'successmod' => 'La déclinaison a été correctement modifiée', + 'successdel' => 'La déclinaison a été correctement effacée', + 'confirmdelete' => 'Confirmez-vous la suppression de la déclinaison ?', ], 'prices' => [ 'title' => 'Prix', diff --git a/resources/views/Admin/Shop/Offers/form.blade.php b/resources/views/Admin/Shop/Offers/form.blade.php index a246da32..360c2955 100644 --- a/resources/views/Admin/Shop/Offers/form.blade.php +++ b/resources/views/Admin/Shop/Offers/form.blade.php @@ -1,62 +1,103 @@
-
-
-
- {{ Form::label('article_id', 'Article') }} - @include('components.form.select', ['name' => 'article_id', 'id_name' => 'article_id', 'list' => $articles ?? null, 'value' => $offer['article_id'] ?? null, 'with_empty' => '', 'class' => 'select2 select_article']) -
-
+
+
+
+ @include('components.form.select', [ + 'name' => 'article_id', + 'id_name' => 'article_id', + 'list' => $articles ?? null, + 'value' => $offer['article_id'] ?? null, + 'with_empty' => '', + 'class' => 'select2 select_article', + 'label' => 'Article', + ]) +
+
-
-
- {{ Form::label('variation_id', 'Déclinaison') }} - @include('components.form.select', ['name' => 'variation_id', 'id_name' => 'variation_id', 'list' => $variations ?? null, 'value' => $offer['variation_id'] ?? null, 'with_empty' => '', 'class' => 'select2 select_variation']) -
-
+
+
+ @include('components.form.select', [ + 'name' => 'variation_id', + 'id_name' => 'variation_id', + 'list' => $variations ?? null, + 'value' => $offer['variation_id'] ?? null, + 'with_empty' => '', + 'class' => 'select2 select_variation', + 'label' => __('shop.packages.name'), + 'required' => true, + ]) +
+
+ @include('components.form.select', [ + 'name' => 'tariff_id', + 'id_name' => 'tariff_id', + 'list' => $tariffs ?? null, + 'value' => $offer['tariff_id'] ?? null, + 'with_empty' => '', + 'class' => 'select2 select_tariffs', + 'label' => 'Tarif', + 'required' => true, + ]) +
+
+ @include('components.form.input', [ + 'name' => 'weight', + 'value' => $offer['weight'] ?? null, + 'label' => 'Poids en g', + ]) +
+
-
-
- {{ Form::label('tariff_id', 'Tarif') }} - @include('components.form.select', ['name' => 'tariff_id', 'id_name' => 'tariff_id', 'list' => $tariffs ?? null, 'value' => $offer['tariff_id'] ?? null, 'with_empty' => '', 'class' => 'select2 select_tariffs']) -
-
- - @component('components.card', ['title' => 'Disponibilité']) -
-
- {{ Form::label('stock_current', 'Appro immédiate') }} - @include('components.form.inputs.money', ['name' => 'stock_current', 'value' => $offer['stock_current'] ?? 0]) -
-
-
-
- {{ Form::label('stock_delayed', 'Appro sur delai') }} - @include('components.form.inputs.money', ['name' => 'stock_delayed', 'value' => $offer['stock_delayed'] ?? 0]) -
-
- {{ Form::label('delay_type', 'Délai type') }} - @include('components.form.input', ['name' => 'delay_type', 'value' => $offer['delay_type'] ?? null]) -
-
-
-
- {{ Form::label('stock_ondemand', 'Appro sur demande') }} - @include('components.form.toggle', ['name' => 'stock_ondemand', 'value' => $offer['stock_ondemand'] ?? 0]) -
-
- {{ Form::label('minimum_ondemand', 'Minimum de quantité') }} - @include('components.form.inputs.money', ['name' => 'minimum_ondemand', 'value' => $offer['minimum_ondemand'] ?? 0]) -
-
- @endcomponent -
-
- @component('components.card', ['title' => 'Previsualisation']) -
-
-
- @endcomponent -
+ @component('components.card', ['title' => 'Disponibilité', 'class' => 'mt-5']) +
+
+ @include('components.form.inputs.money', [ + 'name' => 'stock_current', + 'value' => $offer['stock_current'] ?? 0, + 'label' => 'Appro immédiate', + ]) +
+
+ @include('components.form.inputs.money', [ + 'name' => 'stock_delayed', + 'value' => $offer['stock_delayed'] ?? 0, + 'label' => 'Appro sur delai', + ]) +
+
+ @include('components.form.input', [ + 'name' => 'delay_type', + 'value' => $offer['delay_type'] ?? null, + 'label' => 'Délai type', + ]) +
+
+
+
+ @include('components.form.toggle', [ + 'name' => 'stock_ondemand', + 'value' => $offer['stock_ondemand'] ?? 0, + 'label' => 'Appro sur demande', + 'size' => 'md', + ]) +
+
+ @include('components.form.inputs.money', [ + 'name' => 'minimum_ondemand', + 'value' => $offer['minimum_ondemand'] ?? 0, + 'label' => 'Minimum de quantité', + ]) +
+
+ @endcomponent +
+
+ @component('components.card', ['title' => 'Previsualisation']) +
+
+
+ @endcomponent +
@@ -67,60 +108,60 @@ @include('load.form.select2') @push('js') - -@endpush \ No newline at end of file + handleArticle(); + handleVariation(); + handleTariff(); + initChevron(); + initSaveForm('#offer-form'); + initSelect2(); + @if ($offer['id'] ?? false) + initPreview(); + @endif + +@endpush diff --git a/resources/views/Admin/Shop/Offers/list.blade.php b/resources/views/Admin/Shop/Offers/list.blade.php index feaffac0..61ef8740 100644 --- a/resources/views/Admin/Shop/Offers/list.blade.php +++ b/resources/views/Admin/Shop/Offers/list.blade.php @@ -1,29 +1,34 @@ @extends('layout.index', [ - 'title' => __('shop.offers.title'), - 'subtitle' => __('shop.offers.list'), - 'breadcrumb' => [__('shop.offers.title')] + 'title' => __('shop.offers.title'), + 'subtitle' => __('shop.offers.list'), + 'breadcrumb' => [__('shop.offers.title')] ]) @section('content') - @component('components.card') - @include('components.datatable', ['route' => route('Admin.Shop.Offers.index'), 'model' => 'offers', 'with_filters' => true, 'callback' => 'handleOffer();']) - @component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-offers-filters']) - @include('Admin.Shop.Offers.partials.filters', ['model' => 'offers']) - @endcomponent - @endcomponent + @component('components.card') + @include('components.datatable', [ + 'route' => route('Admin.Shop.Offers.index'), + 'model' => 'offers', + 'with_filters' => true, + 'callback' => 'handleOffer();', + ]) + @component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-offers-filters']) + @include('Admin.Shop.Offers.partials.filters', ['model' => 'offers']) + @endcomponent + @endcomponent @endsection @include('load.form.select2') @include('load.form.toggle') @push('js') - + $(document).ready(function () { + initSelect2(); + }); + @endpush diff --git a/resources/views/Admin/Shop/Offers/partials/filters.blade.php b/resources/views/Admin/Shop/Offers/partials/filters.blade.php index 57e6ea89..927fbd66 100644 --- a/resources/views/Admin/Shop/Offers/partials/filters.blade.php +++ b/resources/views/Admin/Shop/Offers/partials/filters.blade.php @@ -1,14 +1,38 @@
-
- -
- @include('components.form.select', ['name' => 'article_nature_id', 'list' => $article_natures ?? [], 'value' => $filters['article_nature_id'] ?? null, 'class' => 'form-control-sm select2', 'with_empty' => '']) -
-
-
- -
- @include('components.form.select', ['name' => 'package_id', 'list' => $packages ?? [], 'value' => $filters['package_id'] ?? null, 'class' => 'form-control-sm select2', 'with_empty' => '']) -
-
+
+ +
+ @include('components.form.select', [ + 'name' => 'article_nature_id', + 'list' => $article_natures ?? [], + 'value' => $filters['article_nature_id'] ?? null, + 'class' => 'form-control-sm select2', + 'with_empty' => '', + ]) +
+
+
+ +
+ @include('components.form.select', [ + 'name' => 'package_id', + 'list' => $packages ?? [], + 'value' => $filters['package_id'] ?? null, + 'class' => 'form-control-sm select2', + 'with_empty' => '', + ]) +
+
+
+ +
+ @include('components.form.select', [ + 'name' => 'tariff_id', + 'list' => $prices ?? [], + 'value' => $filters['tariff_id'] ?? null, + 'class' => 'form-control-sm select2', + 'with_empty' => '', + ]) +
+
diff --git a/resources/views/Shop/Articles/partials/article.blade.php b/resources/views/Shop/Articles/partials/article.blade.php index 3060f1ec..31e7c5ad 100644 --- a/resources/views/Shop/Articles/partials/article.blade.php +++ b/resources/views/Shop/Articles/partials/article.blade.php @@ -2,7 +2,8 @@
- {{ $product_name }} + {{ $product_name }}

{!! $article['description'] !!}

@@ -19,14 +20,16 @@
@include('Shop.Articles.partials.article_' . $product_type)
- @switch ($article_nature) + @switch ($article_nature ?? 0) @case(1) - @break @case(2) - @break diff --git a/resources/views/Shop/Customers/partials/registration.blade.php b/resources/views/Shop/Customers/partials/registration.blade.php index 839a6a69..5ff2c800 100644 --- a/resources/views/Shop/Customers/partials/registration.blade.php +++ b/resources/views/Shop/Customers/partials/registration.blade.php @@ -36,6 +36,7 @@ 'name' => 'email', 'value' => $customer['email'] ?? '', 'label' => 'Email', + 'required' => true, ])
diff --git a/resources/views/Shop/auth/partials/register.blade.php b/resources/views/Shop/auth/partials/register.blade.php index ddccafd1..d124aced 100644 --- a/resources/views/Shop/auth/partials/register.blade.php +++ b/resources/views/Shop/auth/partials/register.blade.php @@ -34,7 +34,10 @@
- @include('Shop.Customers.partials.address', ['label' => 'Adresse de livraison', 'prefix' => 'delivery_']) + @include('Shop.Customers.partials.address', [ + 'label' => 'Adresse de livraison', + 'prefix' => 'delivery_' + ])
@@ -50,8 +53,7 @@
-{!! Form::close() !!} - + @push('js')