From 9710a7017a2860d34a2dae98dd93ac6d7f1669f8 Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Tue, 14 Jun 2022 22:24:24 +0200 Subject: [PATCH] fixes --- app/Http/Controllers/Shop/SearchController.php | 3 ++- app/Repositories/Shop/Articles.php | 9 ++++++++- app/Repositories/Shop/Searches.php | 3 +-- .../views/Shop/layout/partials/search.blade.php | 12 ++++++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Shop/SearchController.php b/app/Http/Controllers/Shop/SearchController.php index 6504bb1c..5c67329f 100644 --- a/app/Http/Controllers/Shop/SearchController.php +++ b/app/Http/Controllers/Shop/SearchController.php @@ -13,8 +13,9 @@ class SearchController extends Controller { $data = self::init(); $data['articles'] = Searches::getResults($request->input()); - $data['articles_count'] = count($data['articles']); + $data['articles_count'] = $data['articles'] ? count($data['articles']) : 0; $data['search'] = $request->input(); + $data['product_type'] = $request->input('product_type'); return view('Shop.Search.results', $data); } } diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php index f1a8c250..afe7eb69 100644 --- a/app/Repositories/Shop/Articles.php +++ b/app/Repositories/Shop/Articles.php @@ -228,7 +228,14 @@ class Articles $model = $search ? $model->search($search) : $model; $model = $article_nature_id ? $model->byArticleNature($article_nature_id) : $model; $model = $article_nature_ids ? $model->byArticleNatures($article_nature_ids) : $model; - $model = ($product_type == 'botanic') ? $model->botanic() : $model->merchandise(); + switch ($product_type) { + case 'botanic': + $model = $model->botanic(); + break; + case 'merchandise': + $model = $model->merchandise(); + break; + } return $model; } diff --git a/app/Repositories/Shop/Searches.php b/app/Repositories/Shop/Searches.php index 6c8e925e..42563190 100644 --- a/app/Repositories/Shop/Searches.php +++ b/app/Repositories/Shop/Searches.php @@ -8,7 +8,6 @@ class Searches { public static function getResults($options) { - $data = Articles::getArticlesToSell($options); - return $data; + return Articles::getArticlesToSell($options); } } diff --git a/resources/views/Shop/layout/partials/search.blade.php b/resources/views/Shop/layout/partials/search.blade.php index 5ee0a630..68c06632 100644 --- a/resources/views/Shop/layout/partials/search.blade.php +++ b/resources/views/Shop/layout/partials/search.blade.php @@ -1,8 +1,16 @@ -
+
- @include('components.form.select', ['name' => 'type', 'list' => ['Semences & Plants'] ]) + @include('components.form.select', [ + 'name' => 'product_type', + 'list' => [ + 'botanic' => 'Semences & Plants', + 'merchandise' => 'Marchandises', + ], + 'value' => $search['product_type'] ?? null, + + ])