PHP code example of carono / yii2-behaviors

1. Go to this page and download the library: Download carono/yii2-behaviors 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/ */

    

carono / yii2-behaviors example snippets

   
 public function behaviors()
    {
        return [
            'urls' => [
                'class' => UrlBehavior::class,
                'rules' => [
                    [
                        'view-content',
                        'url' => function ($model, $params) {
                            return $model->is_main ? ['/'] : ['/menu/view'] + $params;
                        },
                        'params' => ['id']
                    ],
                    ['view', 'url' => ['/admin/menu/view'], 'params' => ['id'], 'role' => ['root']],
                ]
            ]
        ];
    }