This commit is contained in:
Ludovic CANDELLIER
2022-06-14 22:24:24 +02:00
parent 32044118f3
commit 9710a7017a
4 changed files with 21 additions and 6 deletions

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -8,7 +8,6 @@ class Searches
{
public static function getResults($options)
{
$data = Articles::getArticlesToSell($options);
return $data;
return Articles::getArticlesToSell($options);
}
}

View File

@@ -1,8 +1,16 @@
<form method="get" action="{{ route('Shop.Searches.search') }}" id="search-general">
<form method="method" action="{{ route('Shop.Searches.search') }}" id="search-general">
<div class="input-group">
<div class="input-group-prepend">
@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,
])
</div>
<input type="text" name="search" value="{{ $search['search'] ?? null }}" class="form-control search-btn" aria-label="Chercher">
<div class="input-group-append">