From ddb4520621b2985815be27b43718acc950d37dfd Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Sun, 16 Jul 2023 17:54:44 +0200 Subject: [PATCH] fix shipping --- .../Shop/DeliveryPackagesDataTable.php | 6 +- .../Admin/Shop/DeliveryPackageController.php | 25 +- .../DeliveryTypeCalculationController.php | 32 +-- .../Admin/Shop/DeliveryTypeController.php | 14 -- .../Controllers/Shop/BasketController.php | 16 +- .../Controllers/Shop/CategoryController.php | 64 ++--- app/Menu/Orders.php | 28 ++- app/Menu/Settings.php | 20 +- app/Models/Shop/Category.php | 28 +-- app/Models/Shop/Order.php | 12 +- app/Repositories/Shop/ArticleNatures.php | 55 +---- app/Repositories/Shop/CustomerAddresses.php | 56 +---- app/Repositories/Shop/Dashboards.php | 12 +- app/Repositories/Shop/DeliveryPackages.php | 38 +-- .../Shop/DeliveryTypeCalculations.php | 48 +--- app/Repositories/Shop/DeliveryTypes.php | 38 +-- app/Repositories/Shop/Invoices.php | 8 +- app/Repositories/Shop/OrderMails.php | 44 ++++ app/Repositories/Shop/OrderMetrics.php | 45 ++++ app/Repositories/Shop/Orders.php | 98 +------- app/Traits/Model/Basic.php | 63 +++-- .../Admin/Shop/Deliveries/form.blade.php | 133 ++++++----- .../Shop/DeliveryPackages/create.blade.php | 15 +- .../Shop/DeliveryPackages/edit.blade.php | 17 +- .../Shop/DeliveryPackages/form.blade.php | 78 ++---- .../Shop/DeliveryPackages/list.blade.php | 31 ++- .../Shop/DeliveryPackages/show.blade.php | 36 --- .../DeliveryTypeCalculations/create.blade.php | 15 +- .../DeliveryTypeCalculations/edit.blade.php | 17 +- .../DeliveryTypeCalculations/form.blade.php | 87 ++----- .../DeliveryTypeCalculations/list.blade.php | 1 + .../partials/filters.blade.php | 11 +- .../DeliveryTypeCalculations/show.blade.php | 36 --- .../views/Admin/Shop/Orders/edit.blade.php | 223 +++++++++--------- resources/views/Shop/Articles/show.blade.php | 86 +++---- routes/Admin/Shop/DeliveryTypes.php | 1 - 36 files changed, 640 insertions(+), 897 deletions(-) create mode 100644 app/Repositories/Shop/OrderMails.php create mode 100644 app/Repositories/Shop/OrderMetrics.php delete mode 100644 resources/views/Admin/Shop/DeliveryPackages/show.blade.php delete mode 100644 resources/views/Admin/Shop/DeliveryTypeCalculations/show.blade.php diff --git a/app/Datatables/Shop/DeliveryPackagesDataTable.php b/app/Datatables/Shop/DeliveryPackagesDataTable.php index 3686925d..f0b6d537 100644 --- a/app/Datatables/Shop/DeliveryPackagesDataTable.php +++ b/app/Datatables/Shop/DeliveryPackagesDataTable.php @@ -18,9 +18,9 @@ class DeliveryPackagesDataTable extends DataTable protected function getColumns() { return [ - Column::make('weight')->title('Poids'), - Column::make('weight_flyer')->title('Flyer'), - Column::make('weight_packaging')->title('Packaging'), + Column::make('weight')->title('Poids')->addClass('text-right'), + Column::make('weight_flyer')->title('Flyer')->addClass('text-right'), + Column::make('weight_packaging')->title('Packaging')->addClass('text-right'), $this->makeColumnButtons(), ]; } diff --git a/app/Http/Controllers/Admin/Shop/DeliveryPackageController.php b/app/Http/Controllers/Admin/Shop/DeliveryPackageController.php index fe209e2f..aa7e0eb6 100644 --- a/app/Http/Controllers/Admin/Shop/DeliveryPackageController.php +++ b/app/Http/Controllers/Admin/Shop/DeliveryPackageController.php @@ -11,16 +11,12 @@ class DeliveryPackageController extends Controller { public function index(DeliveryPackagesDataTable $dataTable) { - $data = []; - - return $dataTable->render('Admin.Shop.DeliveryPackages.list', $data); + return $dataTable->render('Admin.Shop.DeliveryPackages.list'); } public function create() { - $data['sale_channels'] = SaleChannels::getOptions(); - - return view('Admin.Shop.DeliveryPackages.create', $data); + return view('Admin.Shop.DeliveryPackages.create'); } public function store(Request $request) @@ -30,17 +26,9 @@ class DeliveryPackageController extends Controller return redirect()->route('Admin.Shop.DeliveryPackages.index'); } - public function show($id) - { - $data['delivery'] = DeliveryPackages::get($id); - - return view('Admin.Shop.DeliveryPackages.view', $data); - } - public function edit($id) { - $data['delivery'] = DeliveryPackages::get($id)->toArray(); - $data['sale_channels'] = SaleChannels::getOptions(); + $data['package'] = DeliveryPackages::get($id)->toArray(); return view('Admin.Shop.DeliveryPackages.edit', $data); } @@ -49,11 +37,4 @@ class DeliveryPackageController extends Controller { return DeliveryPackages::destroy($id); } - - public function toggleActive(Request $request) - { - $data = DeliveryPackages::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0); - - return response()->json(['error' => 0]); - } } diff --git a/app/Http/Controllers/Admin/Shop/DeliveryTypeCalculationController.php b/app/Http/Controllers/Admin/Shop/DeliveryTypeCalculationController.php index 4e9a3eff..09722a24 100644 --- a/app/Http/Controllers/Admin/Shop/DeliveryTypeCalculationController.php +++ b/app/Http/Controllers/Admin/Shop/DeliveryTypeCalculationController.php @@ -4,21 +4,21 @@ namespace App\Http\Controllers\Admin\Shop; use App\Datatables\Shop\DeliveryTypeCalculationsDataTable; use App\Repositories\Shop\DeliveryTypeCalculations; -use App\Repositories\Shop\SaleChannels; +use App\Repositories\Shop\DeliveryTypes; use Illuminate\Http\Request; class DeliveryTypeCalculationController extends Controller { public function index(DeliveryTypeCalculationsDataTable $dataTable) { - $data = []; - - return $dataTable->render('Admin.Shop.DeliveryTypeCalculations.list', $data); + return $dataTable->render('Admin.Shop.DeliveryTypeCalculations.list'); } public function create() { - $data = []; + $data = [ + 'delivery_types' => DeliveryTypes::getOptions(), + ]; return view('Admin.Shop.DeliveryTypeCalculations.create', $data); } @@ -30,18 +30,13 @@ class DeliveryTypeCalculationController extends Controller return redirect()->route('Admin.Shop.DeliveryTypeCalculations.index'); } - public function show($id) - { - $data['delivery'] = DeliveryTypeCalculations::get($id); - - return view('Admin.Shop.DeliveryTypeCalculations.view', $data); - } - public function edit($id) { - $data['delivery'] = DeliveryTypeCalculations::get($id)->toArray(); - $data['sale_channels'] = SaleChannels::getOptions(); - + $data = [ + 'calcul' => DeliveryTypeCalculations::get($id)->toArray(), + 'delivery_types' => DeliveryTypes::getOptions(), + ]; + return view('Admin.Shop.DeliveryTypeCalculations.edit', $data); } @@ -49,11 +44,4 @@ class DeliveryTypeCalculationController extends Controller { return DeliveryTypeCalculations::destroy($id); } - - public function toggleActive(Request $request) - { - $data = DeliveryTypeCalculations::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0); - - return response()->json(['error' => 0]); - } } diff --git a/app/Http/Controllers/Admin/Shop/DeliveryTypeController.php b/app/Http/Controllers/Admin/Shop/DeliveryTypeController.php index 0b7714fc..665d5ded 100644 --- a/app/Http/Controllers/Admin/Shop/DeliveryTypeController.php +++ b/app/Http/Controllers/Admin/Shop/DeliveryTypeController.php @@ -30,13 +30,6 @@ class DeliveryTypeController extends Controller return redirect()->route('Admin.Shop.DeliveryTypes.index'); } - public function show($id) - { - $data['delivery'] = DeliveryTypes::get($id); - - return view('Admin.Shop.DeliveryTypes.view', $data); - } - public function edit($id) { $data['delivery'] = DeliveryTypes::get($id)->toArray(); @@ -49,11 +42,4 @@ class DeliveryTypeController extends Controller { return DeliveryTypes::destroy($id); } - - public function toggleActive(Request $request) - { - $data = DeliveryTypes::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0); - - return response()->json(['error' => 0]); - } } diff --git a/app/Http/Controllers/Shop/BasketController.php b/app/Http/Controllers/Shop/BasketController.php index f775aecf..f7006fc7 100644 --- a/app/Http/Controllers/Shop/BasketController.php +++ b/app/Http/Controllers/Shop/BasketController.php @@ -15,24 +15,24 @@ class BasketController extends Controller { public function getPrice(Request $request) { - $offer_id = $request->input('offer_id'); + $offerId = $request->input('offer_id'); $quantity = $request->input('quantity') ?? 1; - $price = Offers::getPrice($offer_id, $quantity)->price_taxed; + $price = Offers::getPrice($offerId, $quantity)->price_taxed; return number_format($quantity * $price, 2); } public function addBasket(Request $request) { - $offer_id = $request->input('offer_id'); + $offerId = $request->input('offer_id'); $quantity = $request->input('quantity') ?? 1; $update = $request->input('update') ?? false; - return Baskets::addBasket($offer_id, $quantity, $update); + return Baskets::addBasket($offerId, $quantity, $update); } - public function modalBasket($offer_id, $quantity) + public function modalBasket($offerId, $quantity) { - $data['offer'] = Offers::getFull($offer_id)->toArray(); - $data['basket'] = Baskets::addBasket($offer_id, $quantity); + $data['offer'] = Offers::getFull($offerId)->toArray(); + $data['basket'] = Baskets::addBasket($offerId, $quantity); return view('Shop.Baskets.partials.modalBasket', $data); } @@ -65,7 +65,7 @@ class BasketController extends Controller $data = $request->all(); unset($data['_token']); $data['user_id'] = Users::getId(); - Orders::newOrder($data); + Orders::saveOrder($data); return response()->json(['code' => '200']); } diff --git a/app/Http/Controllers/Shop/CategoryController.php b/app/Http/Controllers/Shop/CategoryController.php index 78dcb660..e3e76d69 100644 --- a/app/Http/Controllers/Shop/CategoryController.php +++ b/app/Http/Controllers/Shop/CategoryController.php @@ -19,72 +19,72 @@ class CategoryController extends Controller return $dataTable->render('Shop.Categories.list'); } - public function show(Request $request, $category_id, $article_nature_id = false) + public function show(Request $request, $categoryId, $articleNatureId = false) { - if ($article_nature_id) { - $product_type = ArticleNatures::getProductType($article_nature_id); - dump($product_type); + if ($articleNatureId) { + $productType = ArticleNatures::getProductType($articleNatureId); + dump($productType); exit; } else { - $article_nature = $request->input('article_nature'); - if (!$article_nature) { + $articleNature = $request->input('article_nature'); + if (!$articleNature) { $articleNatures = Articles::getArticleNaturesWithOffers([ - 'category_id' => $category_id, + 'category_id' => $categoryId, ]); if (count($articleNatures) === 1) { - $article_nature = $articleNatures[0]; + $articleNature = $articleNatures[0]; } $productTypes = Articles::getProductTypesWithOffers([ - 'category_id' => $category_id, + 'category_id' => $categoryId, ]); if (count($productTypes) === 1) { - $product_type = $productTypes[0]; + $productType = $productTypes[0]; } } - switch ($article_nature) { + switch ($articleNature) { case 'semences': - $product_type = 'botanic'; - $article_nature_id = 1; + $productType = 'botanic'; + $articleNatureId = 1; break; case 'plants': - $product_type = 'botanic'; - $article_nature_id = 2; + $productType = 'botanic'; + $articleNatureId = 2; break; case 'legumes': - $product_type = 'botanic'; - $article_nature_id = 3; + $productType = 'botanic'; + $articleNatureId = 3; break; default: - if (!($product_type ?? false)) { - $product_type = 'botanic'; - $article_nature_id = 1; - $article_nature = 'semences'; + if (!($productType ?? false)) { + $productType = 'botanic'; + $articleNatureId = 1; + $articleNature = 'semences'; } break; } - // $product_type = ArticleNatures::getProductType($article_nature_id); - // dump($product_type); - // dump($article_nature_id); + // $productType = ArticleNatures::getProductType($articleNatureId); + // dump($productType); + // dump($articleNatureId); // exit; } // exit; $data = [ - 'category' => Categories::getFull($category_id), - 'breadcrumb' => Categories::getAncestorsByCategory($category_id), + 'category' => Categories::getFull($categoryId), + 'breadcrumb' => Categories::getAncestorsByCategory($categoryId), 'display_by_rows' => $request->input('display_by_rows') ?? false, - 'product_type' => $product_type, - 'article_nature' => $article_nature, + 'product_type' => $productType, + 'article_nature' => $articleNature, 'article_natures' => $articleNatures ?? [], 'product_types' => $productTypes ?? [], 'tags_selected' => $request->input('tags') ?? [], 'articles' => Articles::getArticlesToSell([ - 'category_id' => $category_id, + 'category_id' => $categoryId, 'tags' => $request->input('tags') ?? [], - 'product_type' => $product_type ?? false, - 'article_nature_id' => $article_nature_id ?? false, + 'product_type' => $productType ?? false, + 'article_nature_id' => $articleNatureId ?? false, ]), - 'tags' => TagGroups::getWithTagsAndCountOffers($category_id), + 'tags' => TagGroups::getWithTagsAndCountOffers($categoryId), ]; // dump($data); // exit; diff --git a/app/Menu/Orders.php b/app/Menu/Orders.php index a4b1a8d6..da331aec 100644 --- a/app/Menu/Orders.php +++ b/app/Menu/Orders.php @@ -13,13 +13,25 @@ class Orders ->activeIfRoute('orders') ->order(1); - $menu->addTo('orders', 'Commandes', [ 'route' => 'Admin.Shop.Orders.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Admin.Shop.Orders.*'])->order(1); - $menu->addTo('orders', 'Factures', [ 'route' => 'Admin.Shop.Invoices.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Admin.Shop.Invoices.*'])->order(2); - $menu->addTo('orders', 'Avoirs', [ 'route' => 'Admin.Shop.Invoices.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Admin.Shop.Invoices.*'])->order(3); - $menu->addTo('orders', 'Bons de livraison', [ 'route' => 'Admin.Shop.Invoices.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Admin.Shop.Invoices.*'])->order(4); + $menu->addTo('orders', 'Commandes', [ + 'route' => 'Admin.Shop.Orders.index', + 'permission' => 'backend_access', + ])->activeIfRoute(['Admin.Shop.Orders.*'])->order(1); + + $menu->addTo('orders', 'Factures', [ + 'route' => 'Admin.Shop.Invoices.index', + 'permission' => 'backend_access', + ])->activeIfRoute(['Admin.Shop.Invoices.*'])->order(2); +/* + $menu->addTo('orders', 'Avoirs', [ + 'route' => 'Admin.Shop.Invoices.index', + 'permission' => 'backend_access', + ])->activeIfRoute(['Admin.Shop.Invoices.*'])->order(3); + + $menu->addTo('orders', 'Bons de livraison', [ + 'route' => 'Admin.Shop.Invoices.index', + 'permission' => 'backend_access', + ])->activeIfRoute(['Admin.Shop.Invoices.*'])->order(4); +*/ } } diff --git a/app/Menu/Settings.php b/app/Menu/Settings.php index 583ee6fb..d5e5cf96 100644 --- a/app/Menu/Settings.php +++ b/app/Menu/Settings.php @@ -11,15 +11,21 @@ class Settings $menu->add('Paramètres', [ 'permission' => 'backend_access', 'icon' => 'cogs' ]) ->id('settings') ->activeIfRoute('settings') - ->order(1); + ->order(7); - $menu->addTo('settings', __('shop.delivery_types.title'), [ 'route' => 'Admin.Shop.DeliveryTypes.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Admin.Shop.DeliveryTypes.*'])->order(1); + $menu->addTo('settings', __('shop.delivery_types.title'), [ + 'route' => 'Admin.Shop.DeliveryTypes.index', + 'permission' => 'backend_access', + ])->activeIfRoute(['Admin.Shop.DeliveryTypes.*'])->order(1); - $menu->addTo('settings', __('shop.delivery_type_calculations.title'), [ 'route' => 'Admin.Shop.DeliveryTypeCalculations.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Admin.Shop.DeliveryTypeCalculations.*'])->order(2); + $menu->addTo('settings', __('shop.delivery_type_calculations.title'), [ + 'route' => 'Admin.Shop.DeliveryTypeCalculations.index', + 'permission' => 'backend_access', + ])->activeIfRoute(['Admin.Shop.DeliveryTypeCalculations.*'])->order(2); - $menu->addTo('settings', __('shop.delivery_packages.title'), [ 'route' => 'Admin.Shop.DeliveryPackages.index', 'permission' => 'backend_access' ]) - ->activeIfRoute(['Admin.Shop.DeliveryPackages.*'])->order(3); + $menu->addTo('settings', __('shop.delivery_packages.title'), [ + 'route' => 'Admin.Shop.DeliveryPackages.index', + 'permission' => 'backend_access', + ])->activeIfRoute(['Admin.Shop.DeliveryPackages.*'])->order(3); } } diff --git a/app/Models/Shop/Category.php b/app/Models/Shop/Category.php index 10b35aa9..7b6608ac 100644 --- a/app/Models/Shop/Category.php +++ b/app/Models/Shop/Category.php @@ -58,9 +58,9 @@ class Category extends parentCategory return $this->tags()->withCount('Articles'); } - public function scopeByCategory($query, $category_id) + public function scopeByCategory($query, $categoryId) { - return $query->where('category_id', $category_id); + return $query->where('category_id', $categoryId); } public function scopeVisible($query) @@ -78,28 +78,28 @@ class Category extends parentCategory return $query->where('id', '<>', 1); } - public function scopeInRange($query, $_lft, $_rgt) + public function scopeInRange($query, $left, $right) { - return $query->where('_lft', '>=', $_lft)->where('_rgt', '<=', $_rgt); + return $query->where('_lft', '>=', $left)->where('_rgt', '<=', $right); } - public function scopeHasAvailableOffers($query, $sale_channel_id = false) + public function scopeHasAvailableOffers($query, $saleChannelId = false) { - $sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID(); + $saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID(); - return $query->whereHas('articles', function ($query) use ($sale_channel_id) { - $query->WithAvailableOffers($sale_channel_id); + return $query->whereHas('articles', function ($query) use ($saleChannelId) { + $query->WithAvailableOffers($saleChannelId); }); } - public function scopeHasAvailableOffersByCategoryParent($query, $sale_channel_id = false) + public function scopeHasAvailableOffersByCategoryParent($query, $saleChannelId = false) { - $sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID(); + $saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID(); - return $query->whereHas('articles', function ($query) use ($sale_channel_id) { - $query->WithAvailableOffers($sale_channel_id); - })->orWhereHas('descendants.articles', function ($query) use ($sale_channel_id) { - $query->WithAvailableOffers($sale_channel_id); + return $query->whereHas('articles', function ($query) use ($saleChannelId) { + $query->WithAvailableOffers($saleChannelId); + })->orWhereHas('descendants.articles', function ($query) use ($saleChannelId) { + $query->WithAvailableOffers($saleChannelId); }); } } diff --git a/app/Models/Shop/Order.php b/app/Models/Shop/Order.php index a6b0b419..fa3bb9ed 100644 --- a/app/Models/Shop/Order.php +++ b/app/Models/Shop/Order.php @@ -58,14 +58,14 @@ class Order extends Model return $query->where('uuid', $uuid); } - public function scopeByCustomer($query, $customer_id) + public function scopeByCustomer($query, $customerId) { - return $query->where('customer_id', $customer_id); + return $query->where('customer_id', $customerId); } - public function scopeByDelivery($query, $delivery_id) + public function scopeByDelivery($query, $deliveryId) { - return $query->where('delivery_id', $delivery_id); + return $query->where('delivery_id', $deliveryId); } public function scopePreparation($query) @@ -88,9 +88,9 @@ class Order extends Model return $query->where('status', $status); } - public function scopeByPaymentType($query, $payment_type) + public function scopeByPaymentType($query, $paymentType) { - return $query->where('payment_type', $payment_type); + return $query->where('payment_type', $paymentType); } public function scopeByPeriod($query, $start, $end, $field = 'created_at') diff --git a/app/Repositories/Shop/ArticleNatures.php b/app/Repositories/Shop/ArticleNatures.php index e335c8c6..43667906 100644 --- a/app/Repositories/Shop/ArticleNatures.php +++ b/app/Repositories/Shop/ArticleNatures.php @@ -7,13 +7,11 @@ use App\Models\Botanic\Variety; use App\Models\Shop\Article; use App\Models\Shop\ArticleNature; use App\Models\Shop\Merchandise; +use App\Traits\Model\Basic; class ArticleNatures { - public static function getOptions() - { - return ArticleNature::get()->pluck('name', 'id')->toArray(); - } + use Basic; public static function getProductType($id) { @@ -37,12 +35,16 @@ class ArticleNatures switch ($model) { case Specie::class: case Variety::class: - return 1; + $type = 1; + break; case Merchandise::class: - return 2; + $type = 2; + break; + default: + $type = false; } - return false; + return $type; } public static function getProductTypes() @@ -77,14 +79,9 @@ class ArticleNatures return ArticleNature::byProductType($type)->get(); } - public static function getByCategory($category_id) + public static function getByCategory($categoryId) { - return Article::byCategory($category_id)->select('article_nature_id')->distinct()->get(); - } - - public static function getAll() - { - return ArticleNature::orderBy('name', 'asc')->get(); + return Article::byCategory($categoryId)->select('article_nature_id')->distinct()->get(); } public static function getNamesByIds($ids) @@ -94,34 +91,8 @@ class ArticleNatures return array_map('strtolower', $names); } - public static function get($id) + public static function getModel() { - return ArticleNature::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 ArticleNature::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $item = self::get($id); - $ret = $item->update($data); - - return $item; - } - - public static function destroy($id) - { - return ArticleNature::destroy($id); + return ArticleNature::query(); } } diff --git a/app/Repositories/Shop/CustomerAddresses.php b/app/Repositories/Shop/CustomerAddresses.php index 076c09cb..55192dd5 100644 --- a/app/Repositories/Shop/CustomerAddresses.php +++ b/app/Repositories/Shop/CustomerAddresses.php @@ -3,30 +3,18 @@ namespace App\Repositories\Shop; use App\Models\Shop\CustomerAddress; +use App\Traits\Model\Basic; class CustomerAddresses { - public static function getOptions() - { - return CustomerAddress::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray(); - } + use Basic; - public static function getAll() - { - return CustomerAddress::orderBy('name', 'asc')->get(); - } - - public static function get($id) - { - return CustomerAddress::find($id); - } - - public static function add($user_id, $data) + public static function add($userId, $data) { $name = $data['company'] ? $data['company'] : $data['first_name'].' '.$data['last_name']; if ($data['use_for_delivery'] ?? false) { return self::store([ - 'customer_id' => $user_id, + 'customer_id' => $userId, 'name' => $name, 'address' => $data['delivery_address'], 'address2' => $data['delivery_address2'], @@ -35,7 +23,7 @@ class CustomerAddresses ]); } else { return self::store([ - 'customer_id' => $user_id, + 'customer_id' => $userId, 'name' => $name, 'address' => $data['address'], 'address2' => $data['address2'], @@ -45,35 +33,13 @@ class CustomerAddresses } } - public static function store($data) - { - $id = $data['id'] ?? false; - $item = $id ? self::update($data, $id) : self::create($data); - - return $item->id; - } - - public static function create($data) - { - return CustomerAddress::create($data); - } - - public static function update($data, $id = false) - { - $id = $id ? $id : $data['id']; - $delivery = self::get($id); - $delivery->update($data); - - return $delivery; - } - - public static function destroy($id) - { - return CustomerAddress::destroy($id); - } - - public static function toggle_active($id, $active) + public static function toggleActive($id, $active) { return self::update(['active' => $active], $id); } + + public static function getModel() + { + return CustomerAddress::query(); + } } diff --git a/app/Repositories/Shop/Dashboards.php b/app/Repositories/Shop/Dashboards.php index ce68bf17..fb044bc0 100644 --- a/app/Repositories/Shop/Dashboards.php +++ b/app/Repositories/Shop/Dashboards.php @@ -7,14 +7,14 @@ class Dashboards public static function getStats($start, $end) { return [ - 'orders_count' => Orders::countByPeriod($start, $end), - 'orders_sum' => Orders::sumByPeriod($start, $end, 'total_shipped'), - 'orders_avg' => Orders::avgByPeriod($start, $end, 'total_shipped'), + 'orders_count' => OrderMetrics::countByPeriod($start, $end), + 'orders_sum' => OrderMetrics::sumByPeriod($start, $end, 'total_shipped'), + 'orders_avg' => OrderMetrics::avgByPeriod($start, $end, 'total_shipped'), 'offers_count' => Offers::count(), 'clients_count' => Customers::count(), - 'preparationLess24H' => Orders::countInPreparationLess24H(), - 'preparationLess48H' => Orders::countInPreparationLess48H(), - 'preparationMore48H' => Orders::countInPreparationMore48H(), + 'preparationLess24H' => OrderMetrics::countInPreparationLess24H(), + 'preparationLess48H' => OrderMetrics::countInPreparationLess48H(), + 'preparationMore48H' => OrderMetrics::countInPreparationMore48H(), ]; } } diff --git a/app/Repositories/Shop/DeliveryPackages.php b/app/Repositories/Shop/DeliveryPackages.php index 59c06ac7..30863487 100644 --- a/app/Repositories/Shop/DeliveryPackages.php +++ b/app/Repositories/Shop/DeliveryPackages.php @@ -3,42 +3,14 @@ namespace App\Repositories\Shop; use App\Models\Shop\DeliveryPackage; +use App\Traits\Model\Basic; class DeliveryPackages { - public static function getOptions() + use Basic; + + public static function getModel() { - return DeliveryPackage::pluck('name', 'id'); - } - - public static function get($id) - { - return DeliveryPackage::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 DeliveryPackage::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 DeliveryPackage::destroy($id); + return DeliveryPackage::query(); } } diff --git a/app/Repositories/Shop/DeliveryTypeCalculations.php b/app/Repositories/Shop/DeliveryTypeCalculations.php index 4aa26945..4cc092eb 100644 --- a/app/Repositories/Shop/DeliveryTypeCalculations.php +++ b/app/Repositories/Shop/DeliveryTypeCalculations.php @@ -3,52 +3,14 @@ namespace App\Repositories\Shop; use App\Models\Shop\DeliveryTypeCalculation; +use App\Traits\Model\Basic; class DeliveryTypeCalculations { - public static function getByDeliveryType($typeId) + use Basic; + + public static function getModel() { - return DeliveryTypeCalculation::byDeliveryTpe($typeId)->get(); - } - - public static function getPrice($typeId, $weight) - { - return DeliveryTypeCalculation::byDeliveryType($typeId)->byWeight($weight)->get(); - } - - public static function getOptions() - { - return DeliveryTypeCalculation::pluck('name', 'id'); - } - - public static function get($id) - { - return DeliveryTypeCalculation::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 DeliveryTypeCalculation::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 DeliveryTypeCalculation::destroy($id); + return DeliveryTypeCalculation::query(); } } diff --git a/app/Repositories/Shop/DeliveryTypes.php b/app/Repositories/Shop/DeliveryTypes.php index e75e01ad..300d8de0 100644 --- a/app/Repositories/Shop/DeliveryTypes.php +++ b/app/Repositories/Shop/DeliveryTypes.php @@ -3,42 +3,14 @@ namespace App\Repositories\Shop; use App\Models\Shop\DeliveryType; +use App\Traits\Model\Basic; class DeliveryTypes { - public static function getOptions() + use Basic; + + public static function getModel() { - return DeliveryType::pluck('name', 'id'); - } - - public static function get($id) - { - return DeliveryType::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 DeliveryType::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 DeliveryType::destroy($id); + return DeliveryType::query(); } } diff --git a/app/Repositories/Shop/Invoices.php b/app/Repositories/Shop/Invoices.php index cc5fd687..bfd1ac26 100644 --- a/app/Repositories/Shop/Invoices.php +++ b/app/Repositories/Shop/Invoices.php @@ -28,9 +28,9 @@ class Invoices return Invoice::byUUID($uuid)->first(); } - public static function saveInvoice($order_id, $data) + public static function saveInvoice($orderId, $data) { - $data['order_id'] = $order_id; + $data['order_id'] = $orderId; return self::store($data); } @@ -86,9 +86,9 @@ class Invoices public static function getNewRef() { $ref = date('ym').'00000'; - $last_ref = Invoice::orderBy('id', 'desc')->first(); + $lastRef = Invoice::orderBy('id', 'desc')->first(); - return $last_ref ? $last_ref->ref + 1 : $ref + 1; + return $lastRef ? $lastRef->ref + 1 : $ref + 1; } public static function getStatus($id) diff --git a/app/Repositories/Shop/OrderMails.php b/app/Repositories/Shop/OrderMails.php new file mode 100644 index 00000000..72301895 --- /dev/null +++ b/app/Repositories/Shop/OrderMails.php @@ -0,0 +1,44 @@ +customer->email)->send($mail); + } + + public static function sendPreparation($orderId) + { + $order = Orders::get($orderId, ['customer', 'address']); + $mail = new Preparation($order); + + return Mail::to($order->customer->email)->send($mail); + } + + public static function sendShipping($orderId) + { + $order = Orders::get($orderId, ['customer', 'address']); + $mail = new Acheminement($order); + + return Mail::to($order->customer->email)->send($mail); + } +} diff --git a/app/Repositories/Shop/OrderMetrics.php b/app/Repositories/Shop/OrderMetrics.php new file mode 100644 index 00000000..df2f8647 --- /dev/null +++ b/app/Repositories/Shop/OrderMetrics.php @@ -0,0 +1,45 @@ +subHours(24); + $end = Carbon::now(); + + return Order::preparation()->byPeriod($start, $end, 'updated_at')->count(); + } + + public static function countInPreparationLess48H() + { + $start = Carbon::now()->subHours(48); + $end = Carbon::now(); + + return Order::preparation()->byPeriod($start, $end, 'updated_at')->count(); + } + + public static function countInPreparationMore48H() + { + $start = Carbon::now()->subHours(48); + + return Order::preparation()->where('updated_at', '>', $start)->count(); + } + + public static function getTotalByPeriod($start, $end) + { + return self::sumByPeriod($start, $end, 'total_shipped'); + } + + public static function getModel() + { + return Order::query(); + } +} diff --git a/app/Repositories/Shop/Orders.php b/app/Repositories/Shop/Orders.php index 643f0295..8e2f6363 100644 --- a/app/Repositories/Shop/Orders.php +++ b/app/Repositories/Shop/Orders.php @@ -2,18 +2,14 @@ namespace App\Repositories\Shop; -use App\Mail\Acheminement; -use App\Mail\ConfirmationCommande; -use App\Mail\Preparation; use App\Models\Shop\Order; use App\Repositories\Core\DateStats; -use Carbon\Carbon; -use Illuminate\Support\Facades\Mail; +use App\Traits\Model\Basic; use Illuminate\Support\Str; class Orders { - use DateStats; + use Basic, DateStats; public static function getByUUID($uuid) { @@ -38,68 +34,6 @@ class Orders return ($order && $detail) ? Invoices::saveInvoice($order->id, $data) : false; } - public static function testSend($id) - { - self::sendPreparation($id); - } - - public static function sendOrderConfirmed($order_id) - { - $order = self::get($order_id, ['customer', 'address']); - $mail = new ConfirmationCommande($order); - - return Mail::to($order->customer->email)->send($mail); - } - - public static function sendPreparation($order_id) - { - $order = self::get($order_id, ['customer', 'address']); - $mail = new Preparation($order); - - return Mail::to($order->customer->email)->send($mail); - } - - public static function sendShipping($order_id) - { - $order = self::get($order_id, ['customer', 'address']); - $mail = new Acheminement($order); - - return Mail::to($order->customer->email)->send($mail); - } - - public static function count() - { - return Order::count(); - } - - public static function countInPreparationLess24H() - { - $start = Carbon::now()->subHours(24); - $end = Carbon::now(); - - return Order::preparation()->byPeriod($start, $end, 'updated_at')->count(); - } - - public static function countInPreparationLess48H() - { - $start = Carbon::now()->subHours(48); - $end = Carbon::now(); - - return Order::preparation()->byPeriod($start, $end, 'updated_at')->count(); - } - - public static function countInPreparationMore48H() - { - $start = Carbon::now()->subHours(48); - - return Order::preparation()->where('updated_at', '>', $start)->count(); - } - - public static function getTotalByPeriod($start, $end) - { - return self::sumByPeriod($start, $end, 'total_shipped'); - } - public static function edit($id) { return [ @@ -111,16 +45,6 @@ class Orders ]; } - public static function get($id, $relations = false) - { - return $relations ? Order::with($relations)->findOrFail($id) : Order::findOrFail($id); - } - - public static function store($data) - { - return ($data['id'] ?? false) ? self::update($data) : self::create($data); - } - public static function create($data) { OrderStats::increase(); @@ -130,20 +54,6 @@ class Orders return Order::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 Order::destroy($id); - } - public static function download($id) { dump($id); @@ -180,9 +90,9 @@ class Orders public static function getNewRef() { $ref = date('ym').'00000'; - $last_ref = Order::orderBy('id', 'desc')->first(); + $lastRef = Order::orderBy('id', 'desc')->first(); - return $last_ref ? $last_ref->ref + 1 : $ref + 1; + return $lastRef ? $lastRef->ref + 1 : $ref + 1; } public static function getModel() diff --git a/app/Traits/Model/Basic.php b/app/Traits/Model/Basic.php index 42e3e2c9..940815d1 100644 --- a/app/Traits/Model/Basic.php +++ b/app/Traits/Model/Basic.php @@ -3,6 +3,8 @@ namespace App\Traits\Model; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Str; trait Basic { @@ -24,14 +26,38 @@ trait Basic return $data; } - public static function getName($id) + public static function getName($id, $len = false) { - return self::getField($id, 'name'); + $name = self::getField($id, 'name'); + + return $len ? Str::limit($name, $len) : $name; } - public static function getByUUID($uuid) + public static function getUUID($id) { - return self::getByField('uuid', $uuid)->first(); + return self::getField($id, 'uuid'); + } + + public static function getByUUID($uuid, $relations = []) + { + return self::getByField('uuid', $uuid, $relations)->first(); + } + + public static function getIdByUUID($uuid) + { + $model = self::getByUUID($uuid); + + return $model ? $model->id : false; + } + + public static function generateToken() + { + return Hash::make(self::generateUUID()); + } + + public static function generateUUID() + { + return Str::uuid()->toString(); } public static function getFields($field) @@ -39,9 +65,9 @@ trait Basic return self::getAll()->pluck($field); } - public static function getByField($field, $value) + public static function getByField($field, $value, $relations = []) { - return self::getModel()->where($field, $value); + return self::getModel()->with($relations)->where($field, $value)->get(); } public static function getField($id, $field) @@ -58,7 +84,7 @@ trait Basic public static function store($data) { - return ($data['id'] ?? false) ? self::update($data) : self::create($data); + return $data['id'] ?? false ? self::update($data) : self::create($data); } public static function create($data) @@ -87,25 +113,32 @@ trait Basic return self::getModel()->count(); } - public static function firstOrCreate($search, $data) + public static function firstOrCreate($search, $data = false) { - return self::getModel()::firstOrCreate($search, $data); + return self::getModel()->firstOrCreate($search, $data ? $data : $search); } - public static function get($id, $relations = false, $relations_count = false) + public static function deleteByField($field, $value) { - return self::getModelRelations($relations, $relations_count)->find($id); + $model = self::getModel()->where($field, $value); + + return $model ? $model->delete() : false; } - public static function getAll($relations = false, $relations_count = false) + public static function get($id, $relations = false, $relationscount = false) { - return self::getModelRelations($relations, $relations_count)->get(); + return self::getModelRelations($relations, $relationscount)->find($id); } - public static function getModelRelations($relations = false, $relations_count = false) + public static function getAll($relations = false, $relationscount = false) + { + return self::getModelRelations($relations, $relationscount)->get(); + } + + public static function getModelRelations($relations = false, $relationscount = false) { $model = $relations ? self::getModelWithRelations($relations) : false; - $model = $relations_count ? self::getModelWithCountRelations($relations_count, $model) : $model; + $model = $relationscount ? self::getModelWithCountRelations($relationscount, $model) : $model; return $model ? $model : self::getModel(); } diff --git a/resources/views/Admin/Shop/Deliveries/form.blade.php b/resources/views/Admin/Shop/Deliveries/form.blade.php index 27547196..330d91a2 100644 --- a/resources/views/Admin/Shop/Deliveries/form.blade.php +++ b/resources/views/Admin/Shop/Deliveries/form.blade.php @@ -1,55 +1,78 @@
-
-
-
- {{ Form::label('sale_channel_id', __('shop.sale_channels.name')) }} - @include('components.form.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $delivery['sale_channel_id'] ?? null, 'with_empty' => '', 'class' => 'select2']) -
-
-
-
- {{ Form::label('active', __('Actif')) }}
- @include("components.form.toggle", ['name' => 'active', 'value' => $delivery['active'] ?? false, 'on' => __('active'), 'off' => __('inactive')]) -
-
- {{ Form::label('is_public', __('Type')) }} - @include('components.form.toggle', ['name' => 'is_public', 'value' => $delivery['is_public'] ?? false, 'on' => __('public'), 'off' => __('administré')]) -
-
- {{ Form::label('at_house', __('Défaut')) }} - @include('components.form.checkboxes.icheck', ['name' => 'at_house', 'value' => $delivery['at_house'] ?? null]) -
-
-
-
-
-
- {{ Form::label('name', __('Nom')) }} - @include('components.form.input', ['name' => 'name', 'value' => $delivery['name'] ?? null, 'required' => true]) -
-
+
+
+
+ {{ Form::label('sale_channel_id', __('shop.sale_channels.name')) }} + @include('components.form.select', [ + 'name' => 'sale_channel_id', + 'list' => $sale_channels ?? [], + 'value' => $delivery['sale_channel_id'] ?? null, + 'with_empty' => '', + 'class' => 'select2' + ]) +
+
+
+
+ {{ Form::label('active', __('Actif')) }}
+ @include("components.form.toggle", [ + 'name' => 'active', + 'value' => $delivery['active'] ?? false, + 'on' => __('active'), + 'off' => __('inactive') + ]) +
+
+ {{ Form::label('is_public', __('Type')) }} + @include('components.form.toggle', [ + 'name' => 'is_public', + 'value' => $delivery['is_public'] ?? false, + 'on' => __('public'), + 'off' => __('administré') + ]) +
+
+ {{ Form::label('at_house', __('Défaut')) }} + @include('components.form.checkboxes.icheck', [ + 'name' => 'at_house', + 'value' => $delivery['at_house'] ?? null + ]) +
+
+
+
+
+
+ {{ Form::label('name', __('Nom')) }} + @include('components.form.input', [ + 'name' => 'name', + 'value' => $delivery['name'] ?? null, + 'required' => true + ]) +
+
-
-
- {{ Form::label('', __('Description')) }} - -
-
+
+
+ {{ Form::label('', __('Description')) }} + +
+
- @include('components.address', ['with_country' => false]) + @include('components.address', ['with_country' => false]) -
-
- {{ Form::label('event_date_begin', __('Date de début')) }} - @include('components.form.datepicker', ['name' => 'event_date_begin', 'value' => $delivery['event_date_begin'] ?? null]) -
-
- {{ Form::label('event_date_end', __('Date de fin')) }} - @include('components.form.datepicker', ['name' => 'event_date_end', 'value' => $delivery['event_date_end'] ?? null]) -
+
+
+ {{ Form::label('event_date_begin', __('Date de début')) }} + @include('components.form.datepicker', ['name' => 'event_date_begin', 'value' => $delivery['event_date_begin'] ?? null]) +
+
+ {{ Form::label('event_date_end', __('Date de fin')) }} + @include('components.form.datepicker', ['name' => 'event_date_end', 'value' => $delivery['event_date_end'] ?? null]) +
-
-
+
+
@include('components.save') @@ -59,11 +82,11 @@ @push('js') - -@endpush \ No newline at end of file + +@endpush diff --git a/resources/views/Admin/Shop/DeliveryPackages/create.blade.php b/resources/views/Admin/Shop/DeliveryPackages/create.blade.php index bcaacd01..8ae5aca2 100644 --- a/resources/views/Admin/Shop/DeliveryPackages/create.blade.php +++ b/resources/views/Admin/Shop/DeliveryPackages/create.blade.php @@ -1,11 +1,14 @@ @extends('layout.index', [ - 'title' => __('shop.deliveries.title'), - 'subtitle' => __('shop.deliveries.add'), - 'breadcrumb' => [__('shop.deliveries.title'), __('shop.deliveries.add')] + 'title' => __('shop.delivery_packages.title'), + 'subtitle' => __('shop.delivery_packages.add'), ]) @section('content') - {{ Form::open(['route' => 'Admin.Shop.Deliveries.store', 'id' => 'delivery-form', 'autocomplete' => 'off']) }} - @include('Admin.Shop.Deliveries.form') - + {{ Form::open([ + 'route' => 'Admin.Shop.DeliveryPackages.store', + 'id' => 'delivery_package-form', + 'autocomplete' => 'off' + ]) }} + @include('Admin.Shop.DeliveryPackage.form') + @endsection diff --git a/resources/views/Admin/Shop/DeliveryPackages/edit.blade.php b/resources/views/Admin/Shop/DeliveryPackages/edit.blade.php index 1e867bf6..4bde8dc0 100644 --- a/resources/views/Admin/Shop/DeliveryPackages/edit.blade.php +++ b/resources/views/Admin/Shop/DeliveryPackages/edit.blade.php @@ -1,12 +1,15 @@ @extends('layout.index', [ - 'title' => __('shop.deliveries.title'), - 'subtitle' => __('shop.deliveries.edit'), - 'breadcrumb' => [__('shop.deliveries.title')] + 'title' => __('shop.delivery_packages.title'), + 'subtitle' => __('shop.delivery_packages.edit'), ]) @section('content') - {{ Form::open(['route' => 'Admin.Shop.Deliveries.store', 'id' => 'delivery-form', 'autocomplete' => 'off']) }} - - @include('Admin.Shop.Deliveries.form') - + {{ Form::open([ + 'route' => 'Admin.Shop.DeliveryPackages.store', + 'id' => 'delivery_package-form', + 'autocomplete' => 'off' + ]) }} + + @include('Admin.Shop.DeliveryPackages.form') + @endsection diff --git a/resources/views/Admin/Shop/DeliveryPackages/form.blade.php b/resources/views/Admin/Shop/DeliveryPackages/form.blade.php index 27547196..38e18364 100644 --- a/resources/views/Admin/Shop/DeliveryPackages/form.blade.php +++ b/resources/views/Admin/Shop/DeliveryPackages/form.blade.php @@ -1,69 +1,27 @@
-
-
-
- {{ Form::label('sale_channel_id', __('shop.sale_channels.name')) }} - @include('components.form.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $delivery['sale_channel_id'] ?? null, 'with_empty' => '', 'class' => 'select2']) -
-
-
-
- {{ Form::label('active', __('Actif')) }}
- @include("components.form.toggle", ['name' => 'active', 'value' => $delivery['active'] ?? false, 'on' => __('active'), 'off' => __('inactive')]) -
-
- {{ Form::label('is_public', __('Type')) }} - @include('components.form.toggle', ['name' => 'is_public', 'value' => $delivery['is_public'] ?? false, 'on' => __('public'), 'off' => __('administré')]) -
-
- {{ Form::label('at_house', __('Défaut')) }} - @include('components.form.checkboxes.icheck', ['name' => 'at_house', 'value' => $delivery['at_house'] ?? null]) -
-
-
-
-
-
- {{ Form::label('name', __('Nom')) }} - @include('components.form.input', ['name' => 'name', 'value' => $delivery['name'] ?? null, 'required' => true]) -
-
- -
-
- {{ Form::label('', __('Description')) }} - -
-
- - @include('components.address', ['with_country' => false]) - -
-
- {{ Form::label('event_date_begin', __('Date de début')) }} - @include('components.form.datepicker', ['name' => 'event_date_begin', 'value' => $delivery['event_date_begin'] ?? null]) -
-
- {{ Form::label('event_date_end', __('Date de fin')) }} - @include('components.form.datepicker', ['name' => 'event_date_end', 'value' => $delivery['event_date_end'] ?? null]) -
- -
-
+
+ +
+
+ +
+
+ +
+
+ +
-@include('components.save') + -@include('load.form.select2') @include('load.form.save') @push('js') - + @endpush \ No newline at end of file diff --git a/resources/views/Admin/Shop/DeliveryPackages/list.blade.php b/resources/views/Admin/Shop/DeliveryPackages/list.blade.php index 3870bdbd..fc72e884 100644 --- a/resources/views/Admin/Shop/DeliveryPackages/list.blade.php +++ b/resources/views/Admin/Shop/DeliveryPackages/list.blade.php @@ -1,26 +1,23 @@ @extends('layout.index', [ - 'title' => __('shop.deliveries.title'), - 'subtitle' => __('shop.deliveries.list'), - 'breadcrumb' => [__('shop.deliveries.title')] + 'title' => __('shop.delivery_packages.title'), + 'subtitle' => __('shop.delivery_packages.list'), ]) @section('content') - @component('components.card') - @include('components.datatable', ['route' => route('Admin.Shop.Deliveries.index'), 'model' => 'deliveries', 'callback' => 'handleDelivery();']) - @endcomponent + + @include('components.datatable', [ + 'route' => route('Admin.Shop.DeliveryPackages.index'), + 'model' => 'delivery_packages', + ]) + @endsection @include('load.form.select2') -@include('load.form.toggle') @push('js') - -@endpush \ No newline at end of file + +@endpush diff --git a/resources/views/Admin/Shop/DeliveryPackages/show.blade.php b/resources/views/Admin/Shop/DeliveryPackages/show.blade.php deleted file mode 100644 index 1e1cd729..00000000 --- a/resources/views/Admin/Shop/DeliveryPackages/show.blade.php +++ /dev/null @@ -1,36 +0,0 @@ -@extends('layout.index', [ - 'title' => __('products.title'), - 'subtitle' => __('products.title'), - 'breadcrumb' => [__('products.title')] -]) - -@section('content') -
- -
- -
- -
-
-
-

{{ name }}

-

- {{ $product.section.name }}
-

-
-
-

{{ $prix_total }} €

-

{{ $residence['type_produit']['name'] }}

-
- -
- @include('Hestimmo.modules.Lot.partials.carousel') -
-
-
-
-
-
- -@endsection diff --git a/resources/views/Admin/Shop/DeliveryTypeCalculations/create.blade.php b/resources/views/Admin/Shop/DeliveryTypeCalculations/create.blade.php index bcaacd01..a7a7d4ed 100644 --- a/resources/views/Admin/Shop/DeliveryTypeCalculations/create.blade.php +++ b/resources/views/Admin/Shop/DeliveryTypeCalculations/create.blade.php @@ -1,11 +1,14 @@ @extends('layout.index', [ - 'title' => __('shop.deliveries.title'), - 'subtitle' => __('shop.deliveries.add'), - 'breadcrumb' => [__('shop.deliveries.title'), __('shop.deliveries.add')] + 'title' => __('shop.delivery_type_calculations.title'), + 'subtitle' => __('shop.delivery_type_calculations.add'), ]) @section('content') - {{ Form::open(['route' => 'Admin.Shop.Deliveries.store', 'id' => 'delivery-form', 'autocomplete' => 'off']) }} - @include('Admin.Shop.Deliveries.form') - + {{ Form::open([ + 'route' => 'Admin.Shop.DeliveryTypeCalculations.store', + 'id' => 'delivery_type_calculation-form', + 'autocomplete' => 'off' + ]) }} + @include('Admin.Shop.DeliveryTypeCalculations.form') + @endsection diff --git a/resources/views/Admin/Shop/DeliveryTypeCalculations/edit.blade.php b/resources/views/Admin/Shop/DeliveryTypeCalculations/edit.blade.php index 1e867bf6..7ba48daf 100644 --- a/resources/views/Admin/Shop/DeliveryTypeCalculations/edit.blade.php +++ b/resources/views/Admin/Shop/DeliveryTypeCalculations/edit.blade.php @@ -1,12 +1,15 @@ @extends('layout.index', [ - 'title' => __('shop.deliveries.title'), - 'subtitle' => __('shop.deliveries.edit'), - 'breadcrumb' => [__('shop.deliveries.title')] + 'title' => __('shop.delivery_type_calculations.title'), + 'subtitle' => __('shop.delivery_type_calculations.edit'), ]) @section('content') - {{ Form::open(['route' => 'Admin.Shop.Deliveries.store', 'id' => 'delivery-form', 'autocomplete' => 'off']) }} - - @include('Admin.Shop.Deliveries.form') - + {{ Form::open([ + 'route' => 'Admin.Shop.DeliveryTypeCalculations.store', + 'id' => 'delivery_type_calculation-form', + 'autocomplete' => 'off' + ]) }} + + @include('Admin.Shop.DeliveryTypeCalculations.form') + @endsection diff --git a/resources/views/Admin/Shop/DeliveryTypeCalculations/form.blade.php b/resources/views/Admin/Shop/DeliveryTypeCalculations/form.blade.php index 27547196..517c0309 100644 --- a/resources/views/Admin/Shop/DeliveryTypeCalculations/form.blade.php +++ b/resources/views/Admin/Shop/DeliveryTypeCalculations/form.blade.php @@ -1,69 +1,34 @@ -
-
-
-
- {{ Form::label('sale_channel_id', __('shop.sale_channels.name')) }} - @include('components.form.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $delivery['sale_channel_id'] ?? null, 'with_empty' => '', 'class' => 'select2']) -
-
-
-
- {{ Form::label('active', __('Actif')) }}
- @include("components.form.toggle", ['name' => 'active', 'value' => $delivery['active'] ?? false, 'on' => __('active'), 'off' => __('inactive')]) -
-
- {{ Form::label('is_public', __('Type')) }} - @include('components.form.toggle', ['name' => 'is_public', 'value' => $delivery['is_public'] ?? false, 'on' => __('public'), 'off' => __('administré')]) -
-
- {{ Form::label('at_house', __('Défaut')) }} - @include('components.form.checkboxes.icheck', ['name' => 'at_house', 'value' => $delivery['at_house'] ?? null]) -
-
-
-
-
-
- {{ Form::label('name', __('Nom')) }} - @include('components.form.input', ['name' => 'name', 'value' => $delivery['name'] ?? null, 'required' => true]) -
-
- -
-
- {{ Form::label('', __('Description')) }} - -
-
- - @include('components.address', ['with_country' => false]) - -
-
- {{ Form::label('event_date_begin', __('Date de début')) }} - @include('components.form.datepicker', ['name' => 'event_date_begin', 'value' => $delivery['event_date_begin'] ?? null]) -
-
- {{ Form::label('event_date_end', __('Date de fin')) }} - @include('components.form.datepicker', ['name' => 'event_date_end', 'value' => $delivery['event_date_end'] ?? null]) -
- -
-
+
+
+ @include('components.form.select', [ + 'name' => 'type_id', + 'value' => $calcul['type_id'] ?? false, + 'list' => $delivery_types ?? [], + 'label' => __('shop.delivery_types.name'), + ]) +
-@include('components.save') +
+
+ +
+
+ +
+
+ + @include('load.form.select2') @include('load.form.save') @push('js') - -@endpush \ No newline at end of file + +@endpush diff --git a/resources/views/Admin/Shop/DeliveryTypeCalculations/list.blade.php b/resources/views/Admin/Shop/DeliveryTypeCalculations/list.blade.php index 4c29589b..b1a03a84 100644 --- a/resources/views/Admin/Shop/DeliveryTypeCalculations/list.blade.php +++ b/resources/views/Admin/Shop/DeliveryTypeCalculations/list.blade.php @@ -9,6 +9,7 @@ @include('components.datatable', [ 'route' => route('Admin.Shop.DeliveryTypeCalculations.index'), 'model' => 'delivery_type_calculations', + 'with_filters' => true, ]) @endcomponent @endsection diff --git a/resources/views/Admin/Shop/DeliveryTypeCalculations/partials/filters.blade.php b/resources/views/Admin/Shop/DeliveryTypeCalculations/partials/filters.blade.php index efd72f51..0d7df79e 100644 --- a/resources/views/Admin/Shop/DeliveryTypeCalculations/partials/filters.blade.php +++ b/resources/views/Admin/Shop/DeliveryTypeCalculations/partials/filters.blade.php @@ -1,5 +1,10 @@
-
- -
+
+ @include('components.form.select', [ + 'name' => 'type_id', + 'value' => $filters['type_id'] ?? false, + 'list' => $delivery_types ?? [], + 'label' => __('shop.delivery_types.name'), + ]) +
diff --git a/resources/views/Admin/Shop/DeliveryTypeCalculations/show.blade.php b/resources/views/Admin/Shop/DeliveryTypeCalculations/show.blade.php deleted file mode 100644 index 1e1cd729..00000000 --- a/resources/views/Admin/Shop/DeliveryTypeCalculations/show.blade.php +++ /dev/null @@ -1,36 +0,0 @@ -@extends('layout.index', [ - 'title' => __('products.title'), - 'subtitle' => __('products.title'), - 'breadcrumb' => [__('products.title')] -]) - -@section('content') -
- -
- -
- -
-
-
-

{{ name }}

-

- {{ $product.section.name }}
-

-
-
-

{{ $prix_total }} €

-

{{ $residence['type_produit']['name'] }}

-
- -
- @include('Hestimmo.modules.Lot.partials.carousel') -
-
-
-
-
-
- -@endsection diff --git a/resources/views/Admin/Shop/Orders/edit.blade.php b/resources/views/Admin/Shop/Orders/edit.blade.php index 765b5ce9..edf7fc48 100644 --- a/resources/views/Admin/Shop/Orders/edit.blade.php +++ b/resources/views/Admin/Shop/Orders/edit.blade.php @@ -1,115 +1,122 @@ @extends('layout.index', [ - 'title' => __('shop.orders.title'), - 'subtitle' => __('shop.orders.edit'), - 'breadcrumb' => ['Commandes'] + 'title' => __('shop.orders.title'), + 'subtitle' => __('shop.orders.edit'), + 'breadcrumb' => ['Commandes'] ]) @section('content') - {{ Form::open(['route' => 'Admin.Shop.Orders.store', 'id' => 'order-form', 'autocomplete' => 'off']) }} - - -
-
-

{{ $order['delivery']['name'] }}

-
-
- @include('components.form.buttons.button-save') -
-
+ {{ Form::open(['route' => 'Admin.Shop.Orders.store', 'id' => 'order-form', 'autocomplete' => 'off']) }} + + +
+
+

{{ $order['delivery']['name'] }}

+
+
+ @include('components.form.buttons.button-save') +
+
-
-
-

{{ $order['customer']['last_name'] }} {{ $order['customer']['first_name'] }}

-
-
- - @if ($order['address']) - {{ $order['address']['address'] }}
- @isset ($order['address']['address2']) {{ $order['address']['address2'] }}
@endisset - {{ $order['address']['zipcode'] }} {{ $order['address']['city'] }}
- @endif -
-
-
- - @if ($order['delivery_address']) - {{ $order['delivery_address']['address'] }}
- @isset ($order['delivery_address']['address2']) {{ $order['delivery_address']['address2'] }}
@endisset - {{ $order['delivery_address']['zipcode'] }} {{ $order['delivery_address']['city'] }}
- @endif -
-
-
-
-
-
-
- Commande
- du {{ Carbon\Carbon::parse($order['created_at'])->isoFormat('LLLL') }} -
-
- @include('components.form.select', [ - 'label' => 'Statut', - 'name' => 'status', - 'list' => $statuses ?? [], - 'value' => $order['status'], - 'class' => 'select2', - ]) -
-
-
-
- @include('components.form.select', [ - 'label' => 'Canal de vente', - 'name' => 'sale_channel_id', - 'list' => $sale_channels ?? [], - 'value' => $order['sale_channel_id'], - 'class' => 'select2', - ]) -
-
- @include('components.form.select', [ - 'label' => 'Règlement', - 'name' => 'payment_type', - 'list' => $payment_types ?? [], - 'value' => $order['payment_type'], - 'class' => 'select2', - ]) -
-
-
-
- @include('components.form.select', [ - 'label' => 'Type de livraison', - 'name' => 'delivery_type_id', - 'list' => $delivery_types ?? [], - 'value' => $order['delivery_type_id'], - 'with_empty' => '', - ]) -
-
- @include('components.form.input', [ - 'label' => 'Référence colis', - 'name' => 'delivery_ref', - 'value' => $order['delivery_ref'] ?? null, - ]) -
-
- @include('components.form.input', [ - 'label' => 'Lien suivi', - 'name' => 'delivery_link', - 'value' => $order['delivery_link'] ?? null, - ]) -
+
+
+

+ {{ $order['customer']['last_name'] }} {{ $order['customer']['first_name'] }} +

+
+
+ + @if ($order['address']) + {{ $order['address']['address'] }}
+ @isset ($order['address']['address2']) + {{ $order['address']['address2'] }}
+ @endisset + {{ $order['address']['zipcode'] }} {{ $order['address']['city'] }}
+ @endif +
+
+
+ + @if ($order['delivery_address']) + {{ $order['delivery_address']['address'] }}
+ @isset ($order['delivery_address']['address2']) + {{ $order['delivery_address']['address2'] }}
+ @endisset + {{ $order['delivery_address']['zipcode'] }} + {{ $order['delivery_address']['city'] }}
+ @endif +
+
+
+
+
+
+
+ Commande
+ du {{ Carbon\Carbon::parse($order['created_at'])->isoFormat('LLLL') }} +
+
+ @include('components.form.select', [ + 'label' => 'Statut', + 'name' => 'status', + 'list' => $statuses ?? [], + 'value' => $order['status'], + 'class' => 'select2', + ]) +
+
+
+
+ @include('components.form.select', [ + 'label' => 'Canal de vente', + 'name' => 'sale_channel_id', + 'list' => $sale_channels ?? [], + 'value' => $order['sale_channel_id'], + 'class' => 'select2', + ]) +
+
+ @include('components.form.select', [ + 'label' => 'Règlement', + 'name' => 'payment_type', + 'list' => $payment_types ?? [], + 'value' => $order['payment_type'], + 'class' => 'select2', + ]) +
+
+
+
+ @include('components.form.select', [ + 'label' => 'Type de livraison', + 'name' => 'delivery_type_id', + 'list' => $delivery_types ?? [], + 'value' => $order['delivery_type_id'], + 'with_empty' => '', + ]) +
+
+ @include('components.form.input', [ + 'label' => 'Référence colis', + 'name' => 'delivery_ref', + 'value' => $order['delivery_ref'] ?? null, + ]) +
+
+ @include('components.form.input', [ + 'label' => 'Lien suivi', + 'name' => 'delivery_link', + 'value' => $order['delivery_link'] ?? null, + ]) +
-
-
-
-
-
- @include('Admin.Shop.Orders.partials.detail', ['detail_type' => 'commande']) -
-
- - {{ Form::close() }} +
+
+
+
+
+ @include('Admin.Shop.Orders.partials.detail', ['detail_type' => 'commande']) +
+
+
+ {{ Form::close() }} @endsection diff --git a/resources/views/Shop/Articles/show.blade.php b/resources/views/Shop/Articles/show.blade.php index 64487d61..c3127275 100644 --- a/resources/views/Shop/Articles/show.blade.php +++ b/resources/views/Shop/Articles/show.blade.php @@ -1,53 +1,53 @@ @extends('Shop.layout.layout', [ - 'title' => __('home.title'), + 'title' => __('home.title'), ]) @section('content') -
-
-

{{ $article['name'] }}

-
-
-
-
-
- @include('components.multi-images', ['image' => $article['image'], 'images' => $article['images']]) -
-
-
- {!! $article['description']['semences'] ?? null !!} - {!! $article['description']['plants'] ?? null !!} - {!! $article['description']['variety'] ?? null !!} - {!! $article['description']['merchandise'] ?? null !!} +
+
+

{{ $article['name'] }}

+
+
+
+
+
+ @include('components.multi-images', ['image' => $article['image'], 'images' => $article['images']]) +
+
+
+ {!! $article['description']['semences'] ?? null !!} + {!! $article['description']['plants'] ?? null !!} + {!! $article['description']['variety'] ?? null !!} + {!! $article['description']['merchandise'] ?? null !!} - @if ($article['description']['plus'] ?? false) -

Spécificités

- {!! $article['description']['plus'] !!} - @endif + @if ($article['description']['plus'] ?? false) +

Spécificités

+ {!! $article['description']['plus'] !!} + @endif - @if (count($article['tags'] ?? [])) -

Caractéristiques

- @foreach ($article['tags'] as $tag_group => $items) -
- {{ $tag_group }} : - @foreach ($items as $tag) - {{ $tag }} - @endforeach -
- @endforeach - @endif + @if (count($article['tags'] ?? [])) +

Caractéristiques

+ @foreach ($article['tags'] as $tag_group => $items) +
+ {{ $tag_group }} : + @foreach ($items as $tag) + {{ $tag }} + @endforeach +
+ @endforeach + @endif - @if ($article['description']['specie'] ?? false) -

Complément

- {!! $article['description']['specie'] ?? null !!} - {!! $article['description']['producer'] ?? null !!} - @endif + @if ($article['description']['specie'] ?? false) +

Complément

+ {!! $article['description']['specie'] ?? null !!} + {!! $article['description']['producer'] ?? null !!} + @endif -
-
- @include('Shop.Articles.partials.ArticleAddBasket') -
-
+
+
+ @include('Shop.Articles.partials.ArticleAddBasket') +
+
@endsection -@include('load.layout.modal') \ No newline at end of file +@include('load.layout.modal') diff --git a/routes/Admin/Shop/DeliveryTypes.php b/routes/Admin/Shop/DeliveryTypes.php index d31958c5..55c1e08a 100644 --- a/routes/Admin/Shop/DeliveryTypes.php +++ b/routes/Admin/Shop/DeliveryTypes.php @@ -7,5 +7,4 @@ Route::prefix('DeliveryTypes')->name('DeliveryTypes.')->group(function () { Route::post('update', 'DeliveryTypeController@update')->name('update'); Route::post('store', 'DeliveryTypeController@store')->name('store'); Route::get('edit/{id}', 'DeliveryTypeController@edit')->name('edit'); - Route::post('toggleActive', 'DeliveryTypeController@toggleActive')->name('toggleActive'); });