From ec509df665f5f94b1e667c18e041ae52e5aa6b50 Mon Sep 17 00:00:00 2001 From: ludo Date: Sun, 3 Dec 2023 00:40:47 +0100 Subject: [PATCH] better management of shipping and basket summary display --- .../Admin/Shop/PriceListController.php | 35 +-- .../Admin/Shop/TariffController.php | 16 +- .../Controllers/Shop/BasketController.php | 5 +- app/Models/Shop/Customer.php | 5 + app/Repositories/Shop/Baskets.php | 28 +-- app/Repositories/Shop/Customers.php | 27 ++- app/Repositories/Shop/Deliveries.php | 10 + app/Repositories/Shop/Homepages.php | 33 +-- app/Repositories/Shop/InvoicePayments.php | 1 + app/Repositories/Shop/Offers.php | 8 +- app/Repositories/Shop/OrderDetails.php | 31 +-- app/Repositories/Shop/Packages.php | 34 +-- app/Repositories/Shop/PriceListValues.php | 39 +--- app/Repositories/Shop/PriceLists.php | 48 ++-- app/Repositories/Shop/SaleChannels.php | 44 +--- app/Repositories/Shop/Tariffs.php | 58 ++--- .../Admin/Shop/InvoicePayments/form.blade.php | 2 +- .../Articles/partials/addBasket.blade.php | 90 ++++---- resources/views/Shop/Baskets/basket.blade.php | 215 +++++++++--------- .../Baskets/partials/basketTotal.blade.php | 4 +- resources/views/Shop/Orders/order.blade.php | 9 - .../Shop/Orders/partials/addresses.blade.php | 6 +- .../Shop/Orders/partials/deliveries.blade.php | 23 +- .../Shop/Orders/partials/registered.blade.php | 2 + .../Shop/Orders/partials/shipping.blade.php | 17 +- .../components/form/radios/icheck.blade.php | 4 +- 26 files changed, 317 insertions(+), 477 deletions(-) diff --git a/app/Http/Controllers/Admin/Shop/PriceListController.php b/app/Http/Controllers/Admin/Shop/PriceListController.php index 21ad147c..94560702 100644 --- a/app/Http/Controllers/Admin/Shop/PriceListController.php +++ b/app/Http/Controllers/Admin/Shop/PriceListController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Admin\Shop; -use App\Datatables\Shop\PriceListsDataTable; +use App\Datatables\Admin\Shop\PriceListsDataTable; use App\Http\Controllers\Controller; use App\Repositories\Shop\PriceLists; use App\Repositories\Shop\SaleChannels; @@ -14,45 +14,20 @@ class PriceListController extends Controller { public function index(PriceListsDataTable $dataTable) { - $data = []; - - return $dataTable->render('Admin.Shop.PriceLists.list', $data); + return $dataTable->render('Admin.Shop.PriceLists.list'); } - public function create() + public function modalCreate($tariffId) { - $data = []; - $data['sale_channels'] = SaleChannels::getOptions(); - - return view('Admin.Shop.PriceLists.create', $data); - } - - public function edit($id) - { - $data['price_list'] = PriceLists::get($id); - $data['sale_channels'] = SaleChannels::getOptions(); - - return view('Admin.Shop.PriceLists.edit', $data); - } - - public function modalCreate($tariff_id) - { - $data = []; - $data['price_list']['tariff_id'] = $tariff_id; - $data['price_list']['price_list_values'] = array_fill(0, 3, ''); - $data['sale_channels'] = SaleChannels::getOptions(); - $data['statuses'] = Tariffs::getStatuses(); - $data['taxes'] = Taxes::getOptions(); + $data = PriceLists::init($tariffId); return view('Admin.Shop.PriceLists.modal', $data); } public function modalEdit($id) { + $data = PriceLists::init(); $data['price_list'] = PriceLists::edit($id); - $data['sale_channels'] = SaleChannels::getOptions(); - $data['statuses'] = Tariffs::getStatuses(); - $data['taxes'] = Taxes::getOptions(); return view('Admin.Shop.PriceLists.modal', $data); } diff --git a/app/Http/Controllers/Admin/Shop/TariffController.php b/app/Http/Controllers/Admin/Shop/TariffController.php index fb855d85..2fcf89d3 100644 --- a/app/Http/Controllers/Admin/Shop/TariffController.php +++ b/app/Http/Controllers/Admin/Shop/TariffController.php @@ -25,32 +25,22 @@ class TariffController extends Controller public function create() { - $data['sale_channels'] = SaleChannels::getOptions(); - $data['statuses'] = Tariffs::getStatuses(); - $data['tariff_unities'] = TariffUnities::getOptions(); - - $model = new PriceListsDataTable(); - $data['datatables']['price_lists'] = $model->html(); + $data = Tariffs::init(); return view('Admin.Shop.Tariffs.create', $data); } public function show($id) { - $data['tariff'] = Tariffs::getFull($id); + $data['tariff'] = Tariffs::getArray($id); return view('Admin.Shop.Tariffs.view', $data); } public function edit($id) { + $data = Tariffs::init(); $data['tariff'] = Tariffs::get($id); - $data['sale_channels'] = SaleChannels::getOptions(); - $data['statuses'] = Tariffs::getStatuses(); - $data['tariff_unities'] = TariffUnities::getOptions(); - - $model = new PriceListsDataTable(); - $data['datatables']['price_lists'] = $model->html(); return view('Admin.Shop.Tariffs.edit', $data); } diff --git a/app/Http/Controllers/Shop/BasketController.php b/app/Http/Controllers/Shop/BasketController.php index b92ac1c1..292cb7ea 100644 --- a/app/Http/Controllers/Shop/BasketController.php +++ b/app/Http/Controllers/Shop/BasketController.php @@ -5,8 +5,7 @@ namespace App\Http\Controllers\Shop; use App\Http\Controllers\Controller; use App\Repositories\Core\User\ShopCart; use App\Repositories\Shop\Baskets; -use App\Repositories\Shop\Deliveries; -use App\Repositories\Shop\DeliveryTypes; +use App\Repositories\Shop\Customers; use App\Repositories\Shop\Offers; use App\Repositories\Shop\Orders; use App\Repositories\Users; @@ -67,7 +66,7 @@ class BasketController extends Controller public function getBasketTotal($deliveryId = false, $deliveryTypeId = false) { $data['basket'] = Baskets::getBasketTotal($deliveryId, $deliveryTypeId); - + return view('Shop.Baskets.partials.basketTotal', $data); } diff --git a/app/Models/Shop/Customer.php b/app/Models/Shop/Customer.php index aebb8fa9..38f06221 100644 --- a/app/Models/Shop/Customer.php +++ b/app/Models/Shop/Customer.php @@ -69,4 +69,9 @@ class Customer extends Authenticatable { $this->notify(new ResetPassword($token)); } + + public function getNameAttribute() + { + return $this->getAttribute('first_name').' '.$this->getAttribute('last_name'); + } } diff --git a/app/Repositories/Shop/Baskets.php b/app/Repositories/Shop/Baskets.php index c9c2f8fe..9a7928c8 100644 --- a/app/Repositories/Shop/Baskets.php +++ b/app/Repositories/Shop/Baskets.php @@ -6,19 +6,19 @@ use App\Repositories\Core\User\ShopCart; class Baskets { - public static function addBasket($offer_id, $quantity = 1, $update = false) + public static function addBasket($offerId, $quantity = 1, $update = false) { - if (ShopCart::has($offer_id) && ! $quantity) { - $ret = ShopCart::remove($offer_id); + if (ShopCart::has($offerId) && ! $quantity) { + $ret = ShopCart::remove($offerId); } - $data = $quantity ? self::getBasketData($offer_id, $quantity) : false; + $data = $quantity ? self::getBasketData($offerId, $quantity) : false; return $data ? ShopCart::add($data, $update) : false; } public static function getBasketTotal($deliveryId = false, $deliveryTypeId = false) { - $saleChannelId = $deliveryId ? Deliveries::getField($deliveryId, 'sale_channel_id') : SaleChannels::getDefaultID(); + $saleChannelId = Deliveries::getSaleChannelId($deliveryId); return self::getBasketSummary($saleChannelId, $deliveryTypeId); } @@ -36,8 +36,8 @@ class Baskets $prices = Offers::getPrice($item->id, $item->quantity, $saleChannelId); $weight = $offer->weight * $item->quantity; $detail[] = self::getRowDetail($item, $offer, $prices, $weight); - $total += self::getTotal($item->quantity, $prices->price); - $totalTaxed += self::getTotal($item->quantity, $prices->price_taxed); + $total += $prices ? self::getTotal($item->quantity, $prices->price) : false; + $totalTaxed += $prices ? self::getTotal($item->quantity, $prices->price_taxed) : false; $totalWeight += $weight; } $shipping = DeliveryTypeCalculations::getPriceByDeliveryType($deliveryTypeId, $totalWeight); @@ -52,6 +52,7 @@ class Baskets 'count' => ShopCart::count(), 'quantity' => ShopCart::getTotalQuantity(), 'weight' => $totalWeight, + 'sale_channel' => SaleChannels::getArray($saleChannelId), ]; return $data ?? false; @@ -63,12 +64,12 @@ class Baskets 'offer_id' => (int) $item->id, 'name' => $offer->article->name.' ('.$offer->variation->name.')', 'quantity' => (int) $item->quantity, - 'price' => (float) $prices->price, - 'tax' => $prices->price_taxed - $prices->price, - 'price_taxed' => (float) $prices->price_taxed, - 'total' => self::getTotal($item->quantity, $prices->price), - 'total_tax' => self::getTotal($item->quantity, $prices->price_taxed - $prices->price), - 'total_taxed' => self::getTotal($item->quantity, $prices->price_taxed), + 'price' => $prices ? (float) $prices->price : false, + 'tax' => $prices ? $prices->price_taxed - $prices->price : false, + 'price_taxed' => $prices ? (float) $prices->price_taxed : false, + 'total' => $prices ? self::getTotal($item->quantity, $prices->price) : false, + 'total_tax' => $prices ? self::getTotal($item->quantity, $prices->price_taxed - $prices->price) : false, + 'total_taxed' => $prices ? self::getTotal($item->quantity, $prices->price_taxed) : false, 'weight' => $weight, ]; } @@ -110,6 +111,7 @@ class Baskets 'latin' => $offer->article->product->specie->latin ?? false, ]; } + $data['sale_channel'] = Customers::getSaleChannel(); return $data ?? false; } diff --git a/app/Repositories/Shop/Customers.php b/app/Repositories/Shop/Customers.php index 4c89988d..78017600 100644 --- a/app/Repositories/Shop/Customers.php +++ b/app/Repositories/Shop/Customers.php @@ -14,6 +14,18 @@ class Customers { use Basic; + public static function getSaleChannel() + { + return SaleChannels::getDefault(); + } + + public static function getDeliveries() + { + $customer = self::getAuth(); + + return $customer ? $customer->deliveries : Deliveries::getDefault(); + } + public static function getOptions() { return Customer::pluck('last_name', 'id'); @@ -23,13 +35,13 @@ class Customers { $id = $id ? $id : self::getId(); $datatableOrders = new CustomerOrdersDataTable(); - $data = [ + + return [ 'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(), 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(), 'orders' => $datatableOrders->html(), ]; - return $data; } public static function getAvatar($id = false) @@ -48,7 +60,8 @@ class Customers $filename = self::makeAvatarFilename($customer); $name = $customer->first_name.' '.$customer->last_name; $avatar = new Avatar(); - $ret = $avatar->create($name) + + return $avatar->create($name) ->setBackground('#F2B90F') ->setForeground('#335012') ->setBorder(1, '#28a745') @@ -56,8 +69,6 @@ class Customers ->setDimension(36) ->setFontSize(16) ->save($filename); - - return $ret; } public static function makeAvatarFilename($customer) @@ -93,7 +104,7 @@ class Customers { $user = $id ? self::get($id) : self::getAuth(); - return $user ? $user->first_name.' '.$user->last_name : ''; + return $user ? $user->name : ''; } public static function getAuth() @@ -162,7 +173,7 @@ class Customers public static function create($data) { - $user = Customer::create([ + return Customer::create([ 'uuid' => Str::uuid(), 'active' => true, 'first_name' => $data['first_name'], @@ -177,8 +188,6 @@ class Customers 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); - - return $user; } public static function getStorage($filename = false) diff --git a/app/Repositories/Shop/Deliveries.php b/app/Repositories/Shop/Deliveries.php index 5187edb1..77e1ff9c 100644 --- a/app/Repositories/Shop/Deliveries.php +++ b/app/Repositories/Shop/Deliveries.php @@ -9,6 +9,16 @@ class Deliveries { use Basic; + public static function getSaleChannelId($deliveryId) + { + return $deliveryId ? Deliveries::getField($deliveryId, 'sale_channel_id') : SaleChannels::getDefaultID(); + } + + public static function getDefault() + { + return Delivery::active()->atHouse()->first(); + } + public static function getOptions() { return Delivery::orderBy('name', 'asc')->pluck('name', 'id')->toArray(); diff --git a/app/Repositories/Shop/Homepages.php b/app/Repositories/Shop/Homepages.php index ef6c0861..768dd11e 100644 --- a/app/Repositories/Shop/Homepages.php +++ b/app/Repositories/Shop/Homepages.php @@ -3,9 +3,12 @@ namespace App\Repositories\Shop; use App\Models\Shop\Homepage; +use App\Traits\Model\Basic; class Homepages { + use Basic; + public static function getLast() { $model = Homepage::latest('id')->first(); @@ -28,34 +31,8 @@ class Homepages return self::get(3)->text ?? ''; } - public static function get($id) + public static function getModel() { - return Homepage::find($id); - } - - public static function store($data) - { - $item = ($data['id'] ?? false) ? self::update($data) : self::create($data); - - return $item->id; - } - - public static function create($data) - { - return Homepage::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $item->update($data); - - return $item; - } - - public static function destroy($id) - { - return Homepage::destroy($id); + return Homepage::query(); } } diff --git a/app/Repositories/Shop/InvoicePayments.php b/app/Repositories/Shop/InvoicePayments.php index b9e7c703..9d1d9e61 100644 --- a/app/Repositories/Shop/InvoicePayments.php +++ b/app/Repositories/Shop/InvoicePayments.php @@ -28,6 +28,7 @@ class InvoicePayments 'CB', 'CHEQUE', 'VIREMENT', + 'PRELEVEMENT', ]; } diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php index 12aa4f44..2cf7eb87 100644 --- a/app/Repositories/Shop/Offers.php +++ b/app/Repositories/Shop/Offers.php @@ -3,6 +3,7 @@ namespace App\Repositories\Shop; use App\Models\Shop\Offer; +use App\Models\Shop\PriceList; use App\Traits\Model\Basic; class Offers @@ -36,7 +37,7 @@ class Offers return Offer::with([ 'variation', 'article.article_nature', - 'article.product.Specie', + 'article.product', 'article.image', 'price_lists.price_list_values', ])->withPriceListsBySaleChannel($saleChannelId)->byIds($ids)->get(); @@ -67,8 +68,9 @@ class Offers { $saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID(); $offer = Offer::withPriceBySaleChannelByQuantity($saleChannelId, $quantity)->find($id); - - return $offer->price_lists->first()->price_list_values->first(); + $priceList = $offer->price_lists->first(); + + return $priceList ? $priceList->price_list_values->first() : false; } public static function getOffersByArticles($article_ids, $saleChannelId = false) diff --git a/app/Repositories/Shop/OrderDetails.php b/app/Repositories/Shop/OrderDetails.php index c1a3dd5c..ef4edc8d 100644 --- a/app/Repositories/Shop/OrderDetails.php +++ b/app/Repositories/Shop/OrderDetails.php @@ -3,9 +3,12 @@ namespace App\Repositories\Shop; use App\Models\Shop\OrderDetail; +use App\Traits\Model\Basic; class OrderDetails { + use Basic; + public static function saveBasket($order_id, $data) { foreach ($data as $item) { @@ -16,32 +19,8 @@ class OrderDetails return true; } - public static function get($id, $relations = false) + public static function getModel() { - return $relations ? OrderDetail::with($relations)->findOrFail($id) : OrderDetail::findOrFail($id); - } - - public static function store($data) - { - return ($data['id'] ?? false) ? self::update($data) : self::create($data); - } - - public static function create($data) - { - return OrderDetail::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $item->update($data); - - return $item; - } - - public static function delete($id) - { - return OrderDetail::destroy($id); + return OrderDetail::query(); } } diff --git a/app/Repositories/Shop/Packages.php b/app/Repositories/Shop/Packages.php index 2a8932bf..2c493090 100644 --- a/app/Repositories/Shop/Packages.php +++ b/app/Repositories/Shop/Packages.php @@ -3,9 +3,12 @@ namespace App\Repositories\Shop; use App\Models\Shop\Package; +use App\Traits\Model\Basic; class Packages { + use Basic; + public static function getOptions() { return Package::orderBy('value', 'asc')->pluck('value', 'id')->toArray(); @@ -21,35 +24,8 @@ class Packages return self::get($id)->value; } - public static function get($id) + public static function getModel() { - return Package::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 Package::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $item->update($data); - - return $item; - } - - public static function destroy($id) - { - return Package::destroy($id); + return Package::query(); } } diff --git a/app/Repositories/Shop/PriceListValues.php b/app/Repositories/Shop/PriceListValues.php index ce1bb056..67c16eda 100644 --- a/app/Repositories/Shop/PriceListValues.php +++ b/app/Repositories/Shop/PriceListValues.php @@ -4,9 +4,12 @@ namespace App\Repositories\Shop; use App\Models\Shop\Offer; use App\Models\Shop\PriceListValue; +use App\Traits\Model\Basic; class PriceListValues { + use Basic; + public static function getPriceByOffer($offer_id, $quantity = 1, $sale_channel_id = false) { $prices = self::getPricesByOffer($offer_id, $sale_channel_id); @@ -31,16 +34,6 @@ class PriceListValues return PriceListValue::byPriceList($id)->get(); } - public static function getAll() - { - return PriceListValue::orderBy('name', 'asc')->get(); - } - - public static function get($id) - { - return PriceListValue::find($id); - } - public static function storePrices($price_list_id, $values) { foreach ($values as $value) { @@ -51,30 +44,8 @@ class PriceListValues } } - public static function store($data) + public static function getModel() { - $id = isset($data['id']) ? $data['id'] : false; - $price = $id ? self::update($data) : self::create($data); - - return $price; - } - - public static function create($data) - { - return PriceListValue::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $item->update($data); - - return $item; - } - - public static function destroy($id) - { - return PriceListValue::destroy($id); + return PriceListValue::query(); } } diff --git a/app/Repositories/Shop/PriceLists.php b/app/Repositories/Shop/PriceLists.php index e0aa0738..b67336b2 100644 --- a/app/Repositories/Shop/PriceLists.php +++ b/app/Repositories/Shop/PriceLists.php @@ -3,9 +3,25 @@ namespace App\Repositories\Shop; use App\Models\Shop\PriceList; +use App\Traits\Model\Basic; class PriceLists { + use Basic; + + public static function init($tariffId = false) + { + return [ + 'sale_channels' => SaleChannels::getOptions(), + 'statuses' => Tariffs::getStatuses(), + 'taxes' => Taxes::getOptions(), + 'price_list' => [ + 'tariff_id' => $tariffId, + 'price_list_values' => array_fill(0, 3, ''), + ], + ]; + } + public static function getByOfferAndSaleChannel($offer_id, $sale_channel_id) { return PriceList::bySaleChannel($sale_channel_id)->byOffer($offer_id)->get(); @@ -31,15 +47,6 @@ class PriceLists return PriceList::byTariff($id)->get(); } - public static function getOptions() - { - return PriceList::pluck('name', 'id')->toArray(); - } - - public static function getAll() - { - return PriceList::orderBy('name', 'asc')->get(); - } public static function edit($id) { @@ -52,11 +59,6 @@ class PriceLists return $price_list; } - public static function get($id) - { - return PriceList::find($id); - } - public static function getPrices($id) { return PriceList::with('price_list_values')->find($id); @@ -78,22 +80,8 @@ class PriceLists return $price_list; } - public static function create($data) + public static function getModel() { - return PriceList::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $item->update($data); - - return $item; - } - - public static function destroy($id) - { - return PriceList::destroy($id); + return PriceList::query(); } } diff --git a/app/Repositories/Shop/SaleChannels.php b/app/Repositories/Shop/SaleChannels.php index 9ccb8fe7..1cd1aca8 100644 --- a/app/Repositories/Shop/SaleChannels.php +++ b/app/Repositories/Shop/SaleChannels.php @@ -3,9 +3,12 @@ namespace App\Repositories\Shop; use App\Models\Shop\SaleChannel; +use App\Traits\Model\Basic; class SaleChannels { + use Basic; + public static function getDefaultID() { $default = self::getDefault(); @@ -23,45 +26,8 @@ class SaleChannels return SaleChannel::byCode($code)->first(); } - public static function getOptions() + public static function getModel() { - return SaleChannel::orderBy('name', 'asc')->pluck('name', 'id')->toArray(); - } - - public static function getAll() - { - return SaleChannel::orderBy('name', 'asc')->get(); - } - - public static function get($id) - { - return SaleChannel::findOrFail($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 SaleChannel::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $item->update($data); - - return $item; - } - - public static function destroy($id) - { - return SaleChannel::destroy($id); + return SaleChannel::query(); } } diff --git a/app/Repositories/Shop/Tariffs.php b/app/Repositories/Shop/Tariffs.php index f5a33e59..499f072c 100644 --- a/app/Repositories/Shop/Tariffs.php +++ b/app/Repositories/Shop/Tariffs.php @@ -2,10 +2,27 @@ namespace App\Repositories\Shop; +use App\Datatables\Admin\Shop\PriceListsDataTable; use App\Models\Shop\Tariff; +use App\Traits\Model\Basic; class Tariffs { + use Basic; + + public static function init() + { + $model = new PriceListsDataTable(); + + return [ + 'sale_channels' => SaleChannels::getOptions(), + 'statuses' => Tariffs::getStatuses(), + 'tariff_unities' => TariffUnities::getOptions(), + 'datatables' => [ + 'price_lists' => $model->html(), + ], + ]; + } public static function autocomplete($str) { $data = Tariff::byAutocomplete($str)->orderBy('name')->limit(30)->get()->pluck('name', 'id'); @@ -27,11 +44,6 @@ class Tariffs return Tariff::with(['price_lists.price_list_values', 'price_lists.sale_channel'])->find($id); } - public static function getOptions() - { - return Tariff::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray(); - } - public static function getStatus($status_id) { return self::getStatuses()[$status_id]; @@ -42,40 +54,8 @@ class Tariffs return ['Actif', 'Suspendu', 'Invisible', 'Obsolete']; } - public static function getAll() + public static function getModel() { - return Tariff::orderBy('name', 'asc')->get(); - } - - public static function get($id) - { - return Tariff::find($id); - } - - public static function store($data) - { - $id = isset($data['id']) ? $data['id'] : false; - $item = $id ? self::update($data, $id) : self::create($data); - - return $item->id; - } - - public static function create($data) - { - return Tariff::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $item->update($data); - - return $item; - } - - public static function destroy($id) - { - return Tariff::destroy($id); + return Tariff::query(); } } diff --git a/resources/views/Admin/Shop/InvoicePayments/form.blade.php b/resources/views/Admin/Shop/InvoicePayments/form.blade.php index 2eb09e66..66034806 100644 --- a/resources/views/Admin/Shop/InvoicePayments/form.blade.php +++ b/resources/views/Admin/Shop/InvoicePayments/form.blade.php @@ -1,6 +1,6 @@
- @include('components.form.select', [ + @include('components.form.select', [ 'label' => 'Règlement', 'name' => 'payment_type', 'list' => $payment_types ?? [], diff --git a/resources/views/Shop/Articles/partials/addBasket.blade.php b/resources/views/Shop/Articles/partials/addBasket.blade.php index de53a49d..bae6ef7e 100644 --- a/resources/views/Shop/Articles/partials/addBasket.blade.php +++ b/resources/views/Shop/Articles/partials/addBasket.blade.php @@ -1,54 +1,54 @@ @component('components.card', [ - 'id_card' => $model . '-basket', + 'id_card' => $model . '-basket', 'title' => $title, - 'class' => 'mb-3 addBasket ' . ($bgClass ?? null), - 'classTitle' => 'mb-0', - 'outline' => false, + 'class' => 'mb-3 addBasket ' . ($bgClass ?? null), + 'classTitle' => 'mb-0', + 'outline' => false, ]) + @include('components.form.select', [ + 'name' => 'offer_id', + 'id_name' => $model . '-offer_id', + 'list' => collect($data)->pluck('name', 'id')->toArray(), + 'class' => 'select2 mb-2 offer_id', + ]) - @include('components.form.select', [ - 'name' => 'offer_id', - 'id_name' => $model . '-offer_id', - 'list' => collect($data)->pluck('name', 'id')->toArray(), - 'class' => 'select2 mb-2 offer_id', - ]) - -
-
- @include('components.form.inputs.number', [ - 'name' => 'quantity', - 'class' => 'quantity', - 'id_name' => $model . '-quantity', - 'value' => 1, - ]) -
-
- - {{ $data[0]['prices'][0]['price_taxed'] }} - - € TTC -
-
- -
-
- @include('components.form.button', [ - 'metadata' => 'data-type=' . $model, - 'class' => 'btn-success basket w-100 ' . $model, - 'txt' => 'Ajouter au panier', - ]) -
-
+
+
+ @include('components.form.inputs.number', [ + 'name' => 'quantity', + 'class' => 'quantity', + 'id_name' => $model . '-quantity', + 'value' => (int) $data[0]['prices'][0]['quantity'], + 'min' => $data[0]['prices'][0]['quantity'], + 'step' => 1, + ]) +
+
+ + {{ $data[0]['prices'][0]['price_taxed'] }} + + € TTC +
+
+
+
+ @include('components.form.button', [ + 'metadata' => 'data-type=' . $model, + 'class' => 'btn-success basket w-100 ' . $model, + 'txt' => 'Ajouter au panier', + ]) +
+
@endcomponent @push('js') - + @endpush diff --git a/resources/views/Shop/Baskets/basket.blade.php b/resources/views/Shop/Baskets/basket.blade.php index 3bda5fe2..e2ea76a2 100644 --- a/resources/views/Shop/Baskets/basket.blade.php +++ b/resources/views/Shop/Baskets/basket.blade.php @@ -1,121 +1,126 @@ @extends('Shop.layout.layout', [ - 'title' => __('Panier'), + 'title' => __('Panier'), ]) @section('content') - @if ($basket) -
-
-
-
-

Panier

-
-
- Livraison à domicile ...
- Commande en ligne et livraison par voie postale. Attention certains produits ne sont pas disponibles en livraison. - Les sachets disponibles en lignes sont disponibles à la livraison et uniquement quelques plants. -
-
- @foreach ($basket as $nature => $items) -
-
-

{{ $nature }}

- @foreach ($items as $item) - @include('Shop.Baskets.partials.article') - @endforeach -
-
- @endforeach -
-
- - @include('Shop.Baskets.partials.basketTotal') -
-
- COMMANDER -
-
-
-
-
- @else -
-
-

Panier

- Votre panier est vide -
-
- @endif + @if ($basket) +
+
+
+
+

Panier

+
+
+ Livraison à domicile ...
+ Commande en ligne et livraison par voie postale. Attention certains produits ne sont pas disponibles + en livraison. + Les sachets disponibles en lignes sont disponibles à la livraison et uniquement quelques plants. +
+
+ @foreach ($basket as $nature => $items) +
+
+

{{ $nature }}

+ @foreach ($items as $item) + @include('Shop.Baskets.partials.article') + @endforeach +
+
+ @endforeach +
+
+ + @include('Shop.Baskets.partials.basketTotal') +
+
+ COMMANDER +
+
+
+
+
+ @else +
+
+

Panier

+ Votre panier est vide +
+
+ @endif @endsection @push('js') - -@endpush \ No newline at end of file + handleBasket(); + +@endpush diff --git a/resources/views/Shop/Baskets/partials/basketTotal.blade.php b/resources/views/Shop/Baskets/partials/basketTotal.blade.php index ee64248f..d2a3de91 100644 --- a/resources/views/Shop/Baskets/partials/basketTotal.blade.php +++ b/resources/views/Shop/Baskets/partials/basketTotal.blade.php @@ -4,7 +4,7 @@
- {{ $sale_channel['name'] ?? null }} + {{ $basket['sale_channel']['name'] ?? null }}
@@ -18,7 +18,7 @@ € -@if ($basket['shipping']) +@if ($basket['shipping'] ?? false)
LIVRAISON diff --git a/resources/views/Shop/Orders/order.blade.php b/resources/views/Shop/Orders/order.blade.php index 3b7ed4e9..cddcc760 100644 --- a/resources/views/Shop/Orders/order.blade.php +++ b/resources/views/Shop/Orders/order.blade.php @@ -54,15 +54,6 @@ $('#personal_data').collapse('show'); }); - $('#delivery_mode .delivery_mode').click(function() { - var test = $(this).hasClass('at_house'); - if ($(this).hasClass('at_house')) { - $('#delivery_addresses').closest('.card').removeClass('d-none'); - } else { - $('#delivery_addresses').closest('.card').addClass('d-none'); - } - }); - function refreshBasketTotal(deliveryId, deliveryTypeId) { options = deliveryId + '/' + deliveryTypeId; $.get("{{ Route('Shop.Basket.getBasketTotal') }}/" + options, function(data) { diff --git a/resources/views/Shop/Orders/partials/addresses.blade.php b/resources/views/Shop/Orders/partials/addresses.blade.php index 8d24e34d..59347069 100644 --- a/resources/views/Shop/Orders/partials/addresses.blade.php +++ b/resources/views/Shop/Orders/partials/addresses.blade.php @@ -3,10 +3,10 @@
@include('components.form.radios.icheck', [ - 'name' => 'address_id', + 'name' => $prefix . '_address_id', 'val' => $address['id'], - 'id' => 'address_' . $address['id'], - 'value' => count($addresses) === 1 ? $address['id'] : false, + 'id' => $prefix . '_address_' . $address['id'], + 'value' => $address['priority'] || count($addresses) === 1 ? $address['id'] : false, ])
diff --git a/resources/views/Shop/Orders/partials/deliveries.blade.php b/resources/views/Shop/Orders/partials/deliveries.blade.php index 45975cae..7199885f 100644 --- a/resources/views/Shop/Orders/partials/deliveries.blade.php +++ b/resources/views/Shop/Orders/partials/deliveries.blade.php @@ -24,12 +24,21 @@ ci-contre @push('js') @endpush diff --git a/resources/views/Shop/Orders/partials/registered.blade.php b/resources/views/Shop/Orders/partials/registered.blade.php index 575f2634..a6684caf 100644 --- a/resources/views/Shop/Orders/partials/registered.blade.php +++ b/resources/views/Shop/Orders/partials/registered.blade.php @@ -2,6 +2,7 @@ @include('Shop.Orders.partials.addresses', [ 'addresses' => $customer['invoice_addresses'] ?? false, + 'prefix' => 'invoice', ]) @@ -13,6 +14,7 @@ uncollapsed=true> @include('Shop.Orders.partials.addresses', [ 'addresses' => $customer['delivery_addresses'] ?? false, + 'prefix' => 'delivery', ]) @include('Shop.Orders.partials.shipping') diff --git a/resources/views/Shop/Orders/partials/shipping.blade.php b/resources/views/Shop/Orders/partials/shipping.blade.php index 5d9ea1fd..be662342 100644 --- a/resources/views/Shop/Orders/partials/shipping.blade.php +++ b/resources/views/Shop/Orders/partials/shipping.blade.php @@ -30,12 +30,15 @@ @push('js') @endpush diff --git a/resources/views/components/form/radios/icheck.blade.php b/resources/views/components/form/radios/icheck.blade.php index b847b4c4..6ab9554f 100644 --- a/resources/views/components/form/radios/icheck.blade.php +++ b/resources/views/components/form/radios/icheck.blade.php @@ -1,4 +1,4 @@
@include('components.form.radio') - -
\ No newline at end of file + +