chervand/yii2-nav

Yii2 Role Based Navigation Module

Installs: 18

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

v1.1.1 2016-02-25 16:02 UTC

This package is not auto-updated.

Last update: 2024-12-21 19:31:36 UTC


README

Data

TODO: TBA

use \chervand\nav\traits\IdentityTrait;

Assignments

By default Nav assigns to identity's id, but you can implement your own assignment logic. You can do this by overriding [[IdentityTrait::getNavAssignment()]] relation.

class Identity extends ActiveRecord implements IdentityInterface
{
    use \chervand\nav\traits\IdentityTrait;
    ...
    public function getNavAssignment()
    {
        return $this->hasOne(Assignment::className(), ['assignment' => 'role_id'])
            ->orderBy('type ASC');
    }
    ...
}

Widget

<?= chervand\bootstrap\Nav::widget([
    'toggle' => 'collapse',
    'items' => Yii::$app->user->identity->navItemsAsArray,
    'options' => ['class' => 'nav nav-pills nav-stacked'],
]) ?>