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,31 +21,28 @@ 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);
exit;
} else {
$articleNature = $request->input('article_nature');
if (!$articleNature) {
$articleNatures = Articles::getArticleNaturesWithOffers([
'category_id' => $categoryId,
]);
if (! $articleNature) {
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);
}
$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);
}