/** * @param $region * @param bool $big * @return array Data */ public static function getBanner($region, $big = false) { $regions = Banner::dropdownRegions(); $regions = array_keys($regions); if (!in_array($region, $regions)) { return false; } $allBanners = self::getBannerModels(); foreach ($allBanners as $banner) { if (!$banner) { continue; } if (in_array($banner->id, self::$postedBannerIds)) { continue; } if ($big && !$banner->size) { continue; } if ($banner->region != $region) { continue; } self::$postedBannerIds[] = $banner->id; $block = ['view' => '@frontend/views/blocks/banner_block', 'data' => compact('banner')]; return $block; } return false; }