Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categoria::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, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'categoria', $this->categoria])->andFilterWhere(['like', 'seo_slug', $this->seo_slug])->andFilterWhere(['like', 'imagen', $this->imagen]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categoria::find();
     $query->joinWith(['user']);
     $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, 'create_user' => $this->create_user, 'create_time' => $this->create_time, 'update_user' => $this->update_user, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'descripcion', $this->descripcion])->andFilterWhere(['like', 'user.username', $this->user]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
<div class="noticia-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'titulo')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'detalle')->widget(CKEditor::className(), ['options' => ['rows' => 6], 'preset' => 'advance']);
?>

    <?php 
echo $form->field($model, 'categoria_id')->widget(Select2::classname(), ['data' => \yii\helpers\ArrayHelper::map(\common\models\Categoria::find()->all(), 'id', 'categoria'), 'language' => 'es', 'options' => ['placeholder' => 'Seleccione ...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Ejemplo n.º 4
0
$this->title = 'Noticias';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="noticia-index">

   <div class="panel panel-primary">
         <div class="panel-heading">
               <h3 class="panel-title">
  <?php 
echo Html::a('Crear Noticia', ['create'], ['class' => 'btn btn-info']);
?>
               </h3>
         </div>
         <div class="panel-body">
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
      
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'titulo', ['attribute' => 'categoria_id', 'value' => 'categoria.categoria', 'format' => 'raw', 'filter' => Select2::widget(['model' => $searchModel, 'attribute' => 'categoria_id', 'data' => \yii\helpers\ArrayHelper::map(\common\models\Categoria::find()->all(), 'id', 'categoria'), 'options' => ['placeholder' => 'Seleccione...'], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'created_by', 'value' => 'createdBy.name'], ['class' => 'yii\\grid\\ActionColumn']]]);
?>


         </div>
   </div>
</div>
Ejemplo n.º 5
0
 public function actionNoticia($slug)
 {
     $categorias = Categoria::find()->all();
     $noticia = Noticia::find()->where("seo_slug = :slug", [":slug" => $slug])->orderBy('id')->one();
     /*
             CONSULTA DE LOS COMENTARIOS DESDE EL CONTROLADOR
     
        $idNoticia=$noticia->id;
         $comentarios= Comentario::find()
         ->where("noticia_id = :idNoticia", [":idNoticia" => $idNoticia])
         ->all();
     */
     $comentario = new Comentario();
     if ($comentario->load(Yii::$app->request->post())) {
         $comentario->estado = '0';
         $comentario->noticia_id = $noticia->id;
         $comentario->fecha = new Expression("NOW()");
         if ($comentario->save()) {
             Yii::$app->session->setFlash('success', 'Gracias por su comentario');
         } else {
             Yii::$app->session->setFlash('error', 'Su comentario no pudo ser registrado');
         }
         return $this->redirect(["/noticia/{$slug}"]);
     }
     return $this->render('noticia', ['comentario' => $comentario, 'categorias' => $categorias, 'noticia' => $noticia]);
 }
Ejemplo n.º 6
0
use common\models\Categoria;
/* @var $this yii\web\View */
/* @var $model common\models\Menu */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="menu-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
//if(isset($imagenes))
//    $model->imagenes = $imagenes;
?>

    <?php 
echo $form->field($model, 'id_categoria')->dropDownList(ArrayHelper::map(Categoria::find()->all(), 'id', 'nombre'), ['prompt' => 'Seleccione categoría']);
?>

    <?php 
echo $form->field($model, 'nombre')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'descripcion')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'precio')->textInput(['maxlength' => true]);
if (isset($imagenes)) {
    ?>
    <?php