/** * */ public function ruleUnique() { $model = MarketDemand::findOne(['typeID' => $this->typeID, 'stationID' => $this->stationID, 'userID' => $this->userID]); if ($model) { $this->addError('typeID', $this->invTypes->typeName . ' already added to list.'); } }
/** * @param int $demandID * * @return MarketDemand * @throws NotFoundHttpException */ public function loadMarketDemand($demandID) { $model = MarketDemand::findOne(['id' => $demandID, 'userID' => \Yii::$app->user->id]); if (!$model) { throw new NotFoundHttpException('Such market demand does not exist.'); } return $model; }