PHP code example of chervand / yii2-nav

1. Go to this page and download the library: Download chervand/yii2-nav library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chervand / yii2-nav example snippets


use \chervand\nav\traits\IdentityTrait;

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');
    }
    ...
}

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