PHP code example of sasha-x / yii2-admin

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

    

sasha-x / yii2-admin example snippets



'modules' => [
        'admin' => [
            'class' => 'sasha_x\admin\Module',
            'models' => [
                'app\models\User',
                ... other models you need to edit ...
            ],
            //optionally
            'allowTruncate' => true,
            'customViewsPath' => '@app/views/admin',
        ],
    ],

//Need to add custom routing
$config['bootstrap'][] = 'admin';



    //fields list for each action in admin module gets here
    public function scenarios()
    {
        return [
            'default' => ['username', 'email', 'plainPassword', 'status', 'is_admin'],
            'index' => ['username', 'email', 'status', 'is_admin', 'created_at', 'last_login'],
            'view' => ['id', 'username', 'email', 'status', 'is_admin', 'created_at', 'updated_at', 'last_login'],
            'create' => ['username', 'email', 'plainPassword', 'is_admin'],
            'update' => ['username', 'email', 'plainPassword', 'status', 'is_admin'],
        ];
    }


//new default values set
Yii::$container->setDefinitions([
    'yii\data\Pagination' => [
        'defaultPageSize' => 40,
    ],
    'yii\grid\ActionColumn' => [
        'template' => '{update} {delete}',
    ],
    'yii\i18n\Formatter' => [
        'dateFormat' => 'php:Y-m-d',
        'timeFormat' => 'php:H:i:s',
        'datetimeFormat' => 'php:Y-m-d H:i:s',
    ],
]);