Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::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;
     }
     if (isset($this->items)) {
         $query->joinWith('menuAuths');
     }
     $query->andFilterWhere(['id' => $this->id, 'menu_category_id' => $this->menu_category_id, 'parent_id' => $this->parent_id, 'sort' => $this->sort, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'menu_auth.item_name' => $this->items]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'router', $this->router])->andFilterWhere(['like', 'parameter', $this->parameter])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'item_name', $this->item_name])->andFilterWhere(['like', 'target', $this->target])->andFilterWhere(['like', 'protocol', $this->protocol])->andFilterWhere(['like', 'home', $this->home])->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'assoc', $this->assoc]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMenu()
 {
     return $this->hasOne(Menu::className(), ['id' => 'menu_id']);
 }
Ejemplo n.º 3
0
 /**
  * Finds the Menu model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Menu the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Menu::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMenus()
 {
     return $this->hasMany(Menu::className(), ['menu_category_id' => 'id']);
 }
Ejemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMenus()
 {
     return $this->hasMany(Menu::className(), ['parent_id' => 'id']);
 }
Ejemplo n.º 6
0
echo $form->field($model, 'parent_id')->dropDownList(Menu::getList(), ['prompt' => Yii::t('app', 'เลือก')]);
?>
    </div> 
</div> 


<div class="row">   
    <div class="col-sm-3">
        <?php 
echo $form->field($model, 'status')->dropDownList(Menu::getItemStatus(), ['prompt' => Yii::t('app', 'เลือก')]);
?>
    </div>   

    <div class="col-sm-3">  
        <?php 
echo $form->field($model, 'items')->widget(Select2::ClassName(), ['data' => Menu::getAuth(), 'options' => ['placeholder' => 'Select a color ...', 'multiple' => true], 'pluginOptions' => ['tags' => true, 'maximumInputLength' => 10]]);
?>
    </div>   
    <div class="col-sm-3">  
        <?php 
echo $form->field($model, 'protocol')->textInput(['maxlength' => true]);
?>
    </div>   
    <div class="col-sm-3">  
        <?php 
echo $form->field($model, 'home')->dropDownList([1 => '1', 0 => '0'], ['prompt' => '']);
?>
    </div>   
</div>   

Ejemplo n.º 7
0
 public function parentMenu($id)
 {
     $model = Menu::find()->where(['parent_id' => $id, 'status' => '1'])->orderBy(['sort' => SORT_ASC])->all();
     return $model ? $this->genArray($model) : null;
 }
Ejemplo n.º 8
0
//use kartik\widgets\Select2;
/* @var $this yii\web\View */
/* @var $searchModel firdows\menu\models\MenuSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('menu', 'ระบบจัดการเมนู');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class='box box-info'>
    <div class='box-header'>
     <h3 class='box-title'><?php 
echo Html::encode($this->title);
?>
</h3>
    </div><!--box-header -->

    <div class='box-body pad'>

        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'format' => 'html', 'value' => function ($model) {
    return Html::a($model->iconShow . ' ' . $model->title, ['/menu/default/view', 'id' => $model->id]);
}], ['attribute' => 'menu_category_id', 'filter' => MenuCategory::getList(), 'value' => function ($model) {
    return $model->menu_category_id ? $model->menuCategory->title : null;
}], ['attribute' => 'route', 'filter' => Menu::getRouterDistinct()], ['attribute' => 'parent_id', 'filter' => Menu::getParentDistinct(), 'value' => function ($model) {
    return $model->parentTitle;
}], ['attribute' => 'status', 'filter' => Menu::getItemStatus(), 'value' => 'statusLabel'], ['attribute' => 'items', 'filter' => Menu::getItemsListDistinct(), 'value' => 'itemsList', 'headerOptions' => ['width' => '200']], 'sort', ['class' => 'yii\\grid\\ActionColumn']]]);
?>


    </div><!--box-body pad-->
</div><!--box box-info-->