adapt display of article natures by disponibility of offers in shelve

This commit is contained in:
Ludovic CANDELLIER
2023-09-12 23:27:56 +02:00
parent afaf0cc629
commit de5f3d665d
2 changed files with 20 additions and 52 deletions

View File

@@ -21,6 +21,14 @@ class CategoryController extends Controller
public function show(Request $request, $categoryId, $articleNatureId = false)
{
$productTypes = Articles::getProductTypesWithOffers([
'category_id' => $categoryId,
]);
$articleNatures = Articles::getArticleNaturesWithOffers([
'category_id' => $categoryId,
]);
if ($articleNatureId) {
$productType = ArticleNatures::getProductType($articleNatureId);
dump($productType);
@@ -28,24 +36,13 @@ class CategoryController extends Controller
} else {
$articleNature = $request->input('article_nature');
if (! $articleNature) {
$articleNatures = Articles::getArticleNaturesWithOffers([
'category_id' => $categoryId,
]);
if (count($articleNatures) === 1) {
$articleNature = $articleNatures[0];
} else {
$articleNature = 'semences';
}
$productTypes = Articles::getProductTypesWithOffers([
'category_id' => $categoryId,
]);
if (count($productTypes) === 1) {
$productType = $productTypes[0];
}
} else {
$productType = ArticleNatures::getProductTypeBySlug($articleNature);
}
$articleNatureId = ArticleNatures::getIdBySlug($articleNature);
}
$data = [
@@ -65,6 +62,8 @@ class CategoryController extends Controller
]),
'tags' => TagGroups::getWithTagsAndCountOffers($categoryId),
];
// dump($data);
// exit;
return view('Shop.Shelves.shelve', $data);
}

View File

@@ -1,45 +1,14 @@
<div class="row mb-3">
@foreach ($article_natures as $nature)
<div class="col-4">
<div class="row btn h-100 products @if($article_nature == 'semences') shadow2 @endif" data-id="semences">
<div class="row btn h-100 products @if($article_nature == $nature) shadow2 @endif" data-id="{{ $nature }}">
<div class="col-lg-6 col-xs-12">
<img src="/img/article_natures/semences.png" class="img-fluid">
<img src="{{ App\Repositories\Shop\ArticleNatures::getIconBySlug($nature) }}" class="img-fluid">
</div>
<div class="col-lg-6 col-xs-12 green-dark" style="font-size: 2rem;"> Semences </div>
</div>
</div>
<div class="col-4">
<div class="row btn h-100 products @if($article_nature == 'plants') shadow2 @endif" data-id="plants">
<div class="col-lg-6 col-xs-12">
<img src="/img/article_natures/plants.png" class="img-fluid" class="img-fluid">
</div>
<div class="col-lg-6 col-xs-12 green-dark" style="font-size: 2rem;"> Plants </div>
</div>
</div>
<div class="col-4">
<div class="row btn h-100 products @if($article_nature == 'legumes') shadow2 @endif" data-id="legumes">
<div class="col-lg-6 col-xs-12">
<img src="/img/article_natures/legumes.png" class="img-fluid" class="img-fluid">
</div>
<div class="col-lg-6 col-xs-12 green-dark" style="font-size: 2rem;"> Légumes </div>
</div>
</div>
</div>
<div class="row d-none">
<div class="col-12 text-right">
@include('components.form.button', [
'data_id' => 'semences',
'icon' => 'fa-leaf',
'class' => 'products bg-yellow yellow-dark' . (($article_nature == 'semences') ? ' d-none' : ''),
'title' => 'Par semences',
])
@include('components.form.button', [
'data_id' => 'plants',
'icon' => 'fa-seedling',
'class' => 'products bg-green text-white' . (($article_nature == 'plants') ? ' d-none' : ''),
'title' => 'Par plants',
])
</div>
@endforeach
</div>
@push('js')