id); if (!$place) { return 'Place is not found'; } $banners = Banner::find() ->active() ->showTime() //->excludeFree() ->andWhere(['place_id' => $place->id]) ->all(); if (!$banners || $place->isDraft()) { return ''; } /* @var $banner Banner */ $banner = $banners[array_rand($banners)]; return $this->render('banner', [ 'banner' => $banner, ]); } }