Skip to content

Commit

Permalink
Prevent error for clothes without seasons
Browse files Browse the repository at this point in the history
  • Loading branch information
jlbelanger committed Jan 22, 2024
1 parent 1be20bb commit 1411757
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$categoriesFooter = [];
$orderNums = [];
$orderNumsFooter = [];
$seasonsForClothes = [];

foreach ($clothes as $c) {
if (empty($clothesByCategory[$c->category_id])) {
Expand All @@ -25,17 +26,14 @@
$orderNumsFooter[] = $categories[$c->category_id]->order_num_footer;
}
$clothesByCategory[$c->category_id][] = $c;
$seasonsForClothes[$c->id] = [];
}

array_multisort($orderNumsFooter, SORT_ASC, $categoriesFooter);
array_multisort($orderNums, SORT_ASC, $categoriesOutput);

$seasonsForClothes = [];
$clothesSeasons = DB::table('clothes_season')->get();
foreach ($clothesSeasons as $c) {
if (empty($seasonsForClothes[$c->clothes_id])) {
$seasonsForClothes[$c->clothes_id] = [];
}
$seasonsForClothes[$c->clothes_id][] = $c->season_id;
}
foreach ($seasonsForClothes as $clothesId => $seasonIds) {
Expand Down

0 comments on commit 1411757

Please sign in to comment.