for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace zacksleo\yii2\ad\actions;
use yii\base\Action;
use zacksleo\yii2\ad\models\Ad;
use zacksleo\yii2\ad\models\AdPosition;
class SlugAction extends Action
{
public $slug;
public function run()
if (($position = AdPosition::findOne(['slug' => $this->slug, 'status' => AdPosition::STATUS_ACTIVE])) == null) {
return [];
}
return Ad::find()->orderBy('order')
->where(
[
'position_id' => $position->id,
'status' => Ad::STATUS_ACTIVE
]
)->andWhere(['<=', 'available_from', time()])
->andWhere(['>', 'available_to', time()])
->all();