public function actionPecas($id) { $buscaModel = new PecasBusca(); $buscaParametros = Yii::$app->request->queryParams; $buscaParametros['PecasBusca']['categoria_id'] = $id; $dataProvider = $buscaModel->search($buscaParametros); $modelCategoria = Categorias::findOne($id); return $this->render('pecas', ['dataProvider' => $dataProvider, 'buscaModel' => $buscaModel, 'modelCategoria' => $modelCategoria]); }
echo $model->precio; ?> </td> </tr> <tr> <td>Tipo</td><td>Cantidad</td> </tr> <tr> <td>Cantidad</td><td><?php echo $stock->stock; ?> </td> </tr> <tr> <td>Categoria</td><td><?php echo Categorias::findOne($model->categoria)->nombre; ?> </td> </tr> </table> <p> <?php echo Html::a('Editar', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php if ($model->activa == 0) { echo Html::a('Activar', ['activacion', 'id' => $model->id], ['class' => 'btn btn-success']); } else { echo Html::a('Desactivar', ['activacion', 'id' => $model->id], ['class' => 'btn btn-warning']); } ?>
/** * Finds the Categorias model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Categorias the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Categorias::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<h1><?php echo Html::encode($this->title); ?> </h1> <?php $tipo = $model->tipo; if ($tipo == 0) { $tipo = 'Normal'; } elseif ($tipo == 1) { $tipo = 'Por tiempo'; } else { $tipo = 'Hasta agotar stcok'; } ?> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['descripcion_corta', 'descripcion_larga', 'precio', ['attribute' => 'tipo', 'value' => $tipo], ['attribute' => 'categoria', 'value' => Categorias::findOne($model->categoria)->nombre], 'condiciones', 'ubicacion']]); ?> <p> <?php echo Html::a('Editar', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php if ($model->activa == 0) { echo Html::a('Activar', ['activacion', 'id' => $model->id], ['class' => 'btn btn-success']); } else { echo Html::a('Desactivar', ['activacion', 'id' => $model->id], ['class' => 'btn btn-warning']); } ?> </p> </div>