/** * Возвращает JS-объект с подробной информацией о товаре по ид модели OrderedProduct * @param integer $id * @return js-object|json|string */ public function actionDescViewOrdered($id) { Yii::$app->response->format = Response::FORMAT_JSON; $ordered = OrderedProduct::findOne($id); $kodpart = $ordered->kodpart; $namepr = $ordered->dsv; //Имя производителя в модели Products и OrderedProduct $model = Products::findOne(['kodpart' => $kodpart, 'namepr' => $namepr]); if (!empty($model)) { return $model->attributes; } else { return 'empty'; } }
/** * Finds the OrderedProduct model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return OrderedProduct the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = OrderedProduct::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }