Exemple #1
0
 public static function getTree($id = 0)
 {
     $exceptionId = [];
     if ($id != 0) {
         $exceptionNode = \backend\modules\category\models\db\Category::findOne(['id' => $id]);
         $exceptionId[] = $id;
         $exceptionNodes = $exceptionNode->children()->all();
         foreach ($exceptionNodes as $node) {
             $exceptionId[] = $node->id;
         }
     }
     $models = Category::find()->orderBy(['tree' => SORT_ASC, 'lft' => SORT_ASC])->where(['not in', 'id', $exceptionId])->all();
     $arr = [0 => 'Корневая'];
     foreach ($models as $model) {
         $arr[$model->id] = str_repeat("    ", $model->lvl) . $model->name;
     }
     return $arr;
 }
Exemple #2
0
/* @var $this yii\web\View */
/* @var $model backend\modules\manager\models\db\User */
$this->title = 'Профиль: ';
$this->params['breadcrumbs'][] = ['label' => 'Профиль', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Вы уверены что хотите удалить профиль?', 'method' => 'post']]);
?>
        <?php 
echo Html::a('Назад', ['/category'], ['class' => 'btn btn-info']);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['name', ['attribute' => 'parent_id', 'value' => \common\models\db\Category::findOne(['id' => $model->parent_id])->name]]]);
?>

</div>