/** * @param $id * @return string * @throws NotFoundHttpException */ public function actionStatuses($id) { $company = Company::findOne(['id' => $id]); if (!$company) { throw new NotFoundHttpException('Invalid company id'); } if (Yii::$app->request->isAjax) { return $this->renderPartial('statuses', ['statusesProvider' => new ActiveDataProvider(['query' => Status::find()->where(['company_id' => $id]), 'sort' => false])]); } }
/** * @return Company */ public static function next() { $company = self::find()->joinWith(['statuses' => function ($query) { $query->onCondition(['status' => Status::hasParsed()]); }])->where(['company_id' => null])->limit(1)->one(); return $company; }
<?php use app\modules\banks\models\Status; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $statusesProvider yii\data\ActiveDataProvider */ echo GridView::widget(['dataProvider' => $statusesProvider, 'summary' => '', 'emptyText' => 'The company have not parsed yet', 'columns' => [['attribute' => 'status', 'options' => ['width' => '150'], 'value' => function ($company) { return Status::getInfo($company->status); }], ['attribute' => 'status_text', 'label' => 'Text'], ['attribute' => 'created_at', 'options' => ['width' => '150'], 'label' => 'Run', 'format' => 'datetime']]]);