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]); }
public function slug($slug) { $post = \App\Models\Posts::where("post_slug", $slug)->first(); $autor = \App\Models\User::where("id", $post->post_autor)->first(); $categoria = \App\Models\Categorias::where("cat_id", $post->post_categoria_id)->get(); $posts = $this->pega_posts(); // Coloca no Thema $pagina = view('base.depoimento', compact('post', 'autor', 'categoria', 'posts')); return view('themes.layout', compact("pagina")); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Categorias::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'descripcion', $this->descripcion]); return $dataProvider; }
/** * 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.'); } }
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']); } ?>
/** * @return \yii\db\ActiveQuery */ public function getIdcategoria0() { return $this->hasOne(Categorias::className(), ['id' => 'idcategoria']); }
public function pega_posts() { $categoria = \App\Models\Categorias::where("cat_slug", 'noticias')->first(); $noticias_categoria_id = $categoria->cat_id; return \App\Models\Posts::where('post_categoria_id', $noticias_categoria_id)->get(); }
<?php echo $form->field($model, 'descripcion_larga')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'precio')->textInput(); ?> <?php echo $form->field($model, 'tipo')->dropDownList(['Normal', 'Por tiempo', 'Por stock'], ['class' => 'tipoSelected form-control']); ?> <div class="loadTipo"></div> <?php echo $form->field($model, 'categoria')->dropDownList(ArrayHelper::map(Categorias::find()->All(), 'id', 'nombre')); ?> <?php echo $form->field($model, 'condiciones')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'ubicacion')->textInput(['maxlength' => true]); ?> <div id="map-canvas"></div> <?php echo $form->field($model, 'activa')->dropDownList(['Aún no publicada', 'Publicada']); ?>
/** * DELETANDO CATEGORIA || DELETE CATEGORIA * * @param int $id * @return Response */ public function excluirCategoria($id) { if ($id == '') { return 'erro'; } else { $verCatPost = \App\Models\Posts::where('post_categoria_id', $id)->first(); if (count($verCatPost) > 0) { \App\Models\Posts::where('post_id', $verCatPost->post_id)->update(array('post_categoria_id' => 0)); } $categoria = \App\Models\Categorias::where("cat_id", $id)->delete(); // Excluindo posst if ($categoria) { return 'sucesso'; // Retorna sucesso } // verfica se foi deletado } }
/** * @return \yii\db\ActiveQuery */ public function getCategoria() { return $this->hasOne(Categorias::className(), ['id' => 'categoria_id']); }
</form> </div>'; echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right navbar-collapse col-sm-5 col-md-5'], 'items' => [['label' => 'Inicio', 'url' => ['/site/index']], ['label' => 'Mi Perfil', 'url' => ['/usuario/view/'], 'visible' => Yii::$app->user->isGuest ? false : true], Yii::$app->user->isGuest ? ['label' => 'Iniciar sesión', 'url' => ['/site/login']] : ['label' => 'Cerrar sesión (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']], ['label' => 'Registrarse', 'url' => ['/site/sign_in'], 'visible' => Yii::$app->user->isGuest ? true : false]]]); NavBar::end(); ?> <div class="container body-content"> <?php echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?> <div class="col-sm-3 col-lg-2" id="menu" style:"margin-top:60px; position:relative"> <div class="list-group" id="categorias" style="width:100%"> <?php foreach (Categorias::find()->All() as $cate) { ?> <a href=<?php echo Url::to(['categorias/ofertas', 'id' => $cate->id]); ?> class="list-group-item"><?php echo $cate->nombre; ?> </a> <?php } ?> </div> </div> <div class="col-sm-9 col-lg-10">
<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>