@php $products = [ 'bestSales' => $bestSales, 'lastArrivedProducts' => $lastArrivedProducts, 'homeProducts' => $homeProducts, 'discountProducts' => $discountProducts, 'dailyOfferProducts' => $dailyOfferProducts ]; $validSections = []; foreach ($home_settings as $home_setting) { if ($home_setting->home_settings_device == 'website' && $home_setting->home_settings_status == '1') { if (in_array($home_setting->home_settings_key, ['bestSales','lastArrivedProducts','homeProducts','discountProducts','dailyOfferProducts'])) { if(isset($products[$home_setting->home_settings_key]) && is_array($products[$home_setting->home_settings_key]) && sizeof($products[$home_setting->home_settings_key]) > 0) { $validSections[] = $home_setting; } } } } $keys = array_map(function($s) { return $s->home_settings_key; }, $validSections); @endphp