Пример #1
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         Language::saveMessage($this->name);
         // or If the category is the database table name.
         //     Language::saveMessage($this->name, static::tableName());
         // Language::saveMessage($this->description, static::tableName());
         return true;
     }
     return false;
 }
Пример #2
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()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'tree' => $this->tree, 'lft' => $this->lft, 'rgt' => $this->rgt, 'depth' => $this->depth]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Пример #3
0
use cornernote\menu\models\Menu;
use slatiusa\nestable\Nestable;
use yii\helpers\Html;
use cornernote\returnurl\ReturnUrl;
/**
 * @var yii\web\View $this
 */
$this->title = Yii::t('app', 'Menus');
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="menu-index">

    <div class="clearfix">

        <p class="pull-left">
            <?php 
echo Html::a('<span class="fa fa-plus"></span> ' . Yii::t('app', 'Create') . ' ' . Yii::t('app', 'Menu'), ['create', 'ru' => ReturnUrl::getToken()], ['class' => 'btn btn-success modal-remote']);
?>
        </p>

    </div>

    <div class="menu-default-index">
        <?php 
echo Nestable::widget(['query' => Menu::find()->where(['depth' => 0]), 'modelOptions' => ['name' => 'nameAndLinks'], 'pluginEvents' => ['change' => 'function(e) {}'], 'pluginOptions' => ['maxDepth' => 7]]);
?>
    </div>


</div>
Пример #4
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 HttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Menu::findOne($id)) !== null) {
         return $model;
     }
     throw new HttpException(404, 'The requested page does not exist.');
 }