From 0ff39c14015e9057a0d0b0985d8a7a41499a10f2 Mon Sep 17 00:00:00 2001 From: ludo Date: Mon, 11 Dec 2023 21:07:49 +0100 Subject: [PATCH] adjust deliveries by customer --- app/Http/Controllers/Shop/HomeController.php | 4 +- app/Http/Controllers/Shop/OrderController.php | 3 +- .../Requests/Admin/Shop/StoreCustomerPost.php | 26 ++++ app/Repositories/Shop/Deliveries.php | 8 +- .../Admin/Shop/ArticleNatures/form.blade.php | 118 +++++++++--------- .../Admin/Shop/Customers/create.blade.php | 10 +- .../views/Admin/Shop/Customers/edit.blade.php | 13 +- .../views/Admin/Shop/Customers/form.blade.php | 6 + 8 files changed, 108 insertions(+), 80 deletions(-) create mode 100644 app/Http/Requests/Admin/Shop/StoreCustomerPost.php diff --git a/app/Http/Controllers/Shop/HomeController.php b/app/Http/Controllers/Shop/HomeController.php index 33cde3fd..85be3ab5 100644 --- a/app/Http/Controllers/Shop/HomeController.php +++ b/app/Http/Controllers/Shop/HomeController.php @@ -4,7 +4,7 @@ namespace App\Http\Controllers\Shop; use App\Http\Controllers\Controller; use App\Repositories\Shop\Articles; -use App\Repositories\Shop\Homepages; +use App\Repositories\Shop\Contents; use App\Repositories\Shop\TagGroups; use Illuminate\Http\Request; @@ -15,7 +15,7 @@ class HomeController extends Controller $data = [ 'display_by_rows' => $request->input('by_rows') ?? false, 'shelves' => Articles::getArticlesByHomepage(), - 'text' => Homepages::getHomepage(), + 'text' => Contents::getHomepage(), 'tags' => TagGroups::getWithTagsAndCountOffers(), 'no_filter' => true, ]; diff --git a/app/Http/Controllers/Shop/OrderController.php b/app/Http/Controllers/Shop/OrderController.php index 08faf57c..a041c602 100644 --- a/app/Http/Controllers/Shop/OrderController.php +++ b/app/Http/Controllers/Shop/OrderController.php @@ -44,7 +44,8 @@ class OrderController extends Controller $data = [ 'customer' => $customer ? $customer->toArray() : false, 'basket' => Baskets::getBasketTotal(), - 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(), + // 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(), + 'deliveries' => Deliveries::getByCustomer()->toArray(), 'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()), ]; diff --git a/app/Http/Requests/Admin/Shop/StoreCustomerPost.php b/app/Http/Requests/Admin/Shop/StoreCustomerPost.php new file mode 100644 index 00000000..fdaeba3b --- /dev/null +++ b/app/Http/Requests/Admin/Shop/StoreCustomerPost.php @@ -0,0 +1,26 @@ + 'required', + 'last_name' => 'required', + 'email' => 'required', + 'address' => 'required', + 'zipcode' => 'required', + 'city' => 'required', + 'sale_channels[]' => 'required', + ]; + } +} diff --git a/app/Repositories/Shop/Deliveries.php b/app/Repositories/Shop/Deliveries.php index 6db89a98..a9534e3c 100644 --- a/app/Repositories/Shop/Deliveries.php +++ b/app/Repositories/Shop/Deliveries.php @@ -19,15 +19,15 @@ class Deliveries public static function getByCustomer($customerId = false) { - $customer = Customers::get($customerId); - $saleChannels = $customer->sale_channels->pluck('id')->toArray(); + $customer = $customerId ? Customers::get($customerId) : Customers::getAuth(); + $saleChannels = $customer ? $customer->sale_channels->pluck('id')->toArray() : false; - return self::getBySaleChannels($saleChannels); + return $saleChannels ? self::getBySaleChannels($saleChannels) : false; } public static function getBySaleChannels($saleChannels) { - return Delivery::bySaleChannels($saleChannels)->get(); + return Delivery::bySaleChannels($saleChannels)->with('sale_channel')->get(); } public static function getSaleChannelId($deliveryId) diff --git a/resources/views/Admin/Shop/ArticleNatures/form.blade.php b/resources/views/Admin/Shop/ArticleNatures/form.blade.php index d1de5068..59fe2c27 100644 --- a/resources/views/Admin/Shop/ArticleNatures/form.blade.php +++ b/resources/views/Admin/Shop/ArticleNatures/form.blade.php @@ -1,55 +1,55 @@
-
-
-
- {{ Form::label('product_type', 'Famille de produit') }} - @include('components.form.select', [ - 'name' => 'product_type', - 'value' => $article_nature['product_type'] ?? null, - 'list' => $product_types ?? null, - 'required' => true, - ]) -
-
- {{ Form::label('name', 'Nom') }} - @include('components.form.input', [ - 'name' => 'name', - 'value' => $article_nature['name'] ?? null, - 'required' => true, - ]) -
-
-
-
- {{ Form::label('description', 'Description') }} - @include('components.form.textarea', [ - 'name' => 'description', - 'value' => $article_nature['description'] ?? null, - 'class' => 'editor', - 'required' => false, - ]) -
-
-
+
+
+
+ {{ Form::label('product_type', 'Famille de produit') }} + @include('components.form.select', [ + 'name' => 'product_type', + 'value' => $article_nature['product_type'] ?? null, + 'list' => $product_types ?? null, + 'required' => true, + ]) +
+
+ {{ Form::label('name', 'Nom') }} + @include('components.form.input', [ + 'name' => 'name', + 'value' => $article_nature['name'] ?? null, + 'required' => true, + ]) +
+
+
+
+ {{ Form::label('description', 'Description') }} + @include('components.form.textarea', [ + 'name' => 'description', + 'value' => $article_nature['description'] ?? null, + 'class' => 'editor', + 'required' => false, + ]) +
+
+
-
- - @include('components.widgets.imgUpload', [ - 'name' => 'icon', - 'id_name' => 'icon', - 'file' => $article_nature['icon'] ?? false, - ]) - -
-
- - @include('components.widgets.imgUpload', [ - 'name' => 'icon_selection', - 'id_name' => 'icon_selection', - 'file' => $article_nature['icon_selection'] ?? false, - ]) - -
+
+ + @include('components.widgets.imgUpload', [ + 'name' => 'icon', + 'id_name' => 'icon', + 'file' => $article_nature['icon'] ?? false, + ]) + +
+
+ + @include('components.widgets.imgUpload', [ + 'name' => 'icon_selection', + 'id_name' => 'icon_selection', + 'file' => $article_nature['icon_selection'] ?? false, + ]) + +
@@ -59,11 +59,13 @@ @include('load.form.save') @push('js') - -@endpush \ No newline at end of file + {!! JsValidator::formRequest('App\Http\Requests\Admin\Shop\StoreArticleNaturePost', '#article_nature-form') !!} + + +@endpush diff --git a/resources/views/Admin/Shop/Customers/create.blade.php b/resources/views/Admin/Shop/Customers/create.blade.php index 53c18680..5a3fd9d2 100644 --- a/resources/views/Admin/Shop/Customers/create.blade.php +++ b/resources/views/Admin/Shop/Customers/create.blade.php @@ -1,11 +1,9 @@ @extends('layout.index', [ - 'title' => __('shop.customers.title'), - 'subtitle' => __('shop.customers.add'), - 'breadcrumb' => [__('shop.customers.title')] + 'title' => __('shop.customers.title'), + 'subtitle' => __('shop.customers.add'), + 'breadcrumb' => [__('shop.customers.title')], ]) @section('content') - {{ Form::open(['route' => 'Admin.Shop.Customers.store', 'id' => 'customer-form', 'autocomplete' => 'off']) }} - @include('Admin.Shop.Customers.form') - + @include('Admin.Shop.Customers.form') @endsection diff --git a/resources/views/Admin/Shop/Customers/edit.blade.php b/resources/views/Admin/Shop/Customers/edit.blade.php index 98cbf194..92b6ff15 100644 --- a/resources/views/Admin/Shop/Customers/edit.blade.php +++ b/resources/views/Admin/Shop/Customers/edit.blade.php @@ -1,14 +1,9 @@ @extends('layout.index', [ - 'title' => __('shop.customers.title'), - 'subtitle' => __('shop.customers.edit'), - 'breadcrumb' => [__('shop.customers.title')] + 'title' => __('shop.customers.title'), + 'subtitle' => __('shop.customers.edit'), + 'breadcrumb' => [__('shop.customers.title')], ]) @section('content') - - {{ Form::open(['route' => 'Admin.Shop.Customers.store', 'id' => 'customer-form', 'autocomplete' => 'off']) }} - - @include('Admin.Shop.Customers.form') - - + @include('Admin.Shop.Customers.form') @endsection diff --git a/resources/views/Admin/Shop/Customers/form.blade.php b/resources/views/Admin/Shop/Customers/form.blade.php index 2e31bcd2..626543ab 100644 --- a/resources/views/Admin/Shop/Customers/form.blade.php +++ b/resources/views/Admin/Shop/Customers/form.blade.php @@ -1,3 +1,6 @@ +f{{ Form::open(['route' => 'Admin.Shop.Customers.store', 'id' => 'customer-form', 'autocomplete' => 'off']) }} + +
@@ -116,6 +119,7 @@
+ @@ -123,6 +127,8 @@ @include('load.form.select2') @push('js') + {!! JsValidator::formRequest('App\Http\Requests\Admin\Shop\StoreCustomerPost', '#customer-form') !!} +