public function actionVerproducto($id) { $this->layout = 'frontoffice'; $model = $this->findModel($id); $temporal = Temporales::findOne($id); if ($temporal != null) { return $this->render('verProducto', ['temporal' => $temporal, 'model' => $model]); } else { $stock = Stock::findOne($id); if ($stock != null) { return $this->render('verProducto', ['stock' => $stock, 'model' => $model]); } } return $this->render('verProducto', ['model' => $this->findModel($id)]); }
/** * Finds the Temporales model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Temporales the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Temporales::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }