lito

lito

这家伙有点懒,还没写个性签名!

  • 财富值50
  • 威望值0
  • 总积分110

个人信息

  • 有个问题 假如用户 id为1 的订单为空 那么Customer::findModel($id)->orders 也为空,view层该如何处理这种空?

  • 爬啊爬怕怕!!Mark

  • 2016-08-11 已签到
    连续签到1天,获得了5个金钱
  • 我使用Yii2的基本应用程序模板安装完成yii2-admin后,查看路由只能看到admin下的路由列表
    但是,路由列表中看不到app\controller下的控制器?请问为什么

    module配置如下:

    <?php
    return  [ 
            'admin' => [
                'class' => 'mdm\admin\Module',
                'layout'=>'left-menu',
                'mainLayout' => '@app/views/layouts/main.php',
            ],
            
            'controllerMap' => [
                'assignment' => [
                    'class' => 'mdm\admin\controllers\AssignmentController',
                    /* 'userClassName' => 'app\models\User', */
                    'idField' => 'user_id',
                    'usernameField' => 'username',
                    'fullnameField' => 'profile.full_name',
                    'extraColumns' => [
                         [
                            'attribute' => 'full_name',
                            'label' => 'Full Name',
                            'value' => function($model, $key, $index, $column) {
                                return $model->profile->full_name;
                            },
                         ],
                         [
                         'attribute' => 'dept_name',
                         'label' => 'Department',
                             'value' => function($model, $key, $index, $column) {
                                 return $model->profile->dept->name;
                                },
                         ],
                         [
                         'attribute' => 'post_name',
                             'label' => 'Post',
                                 'value' => function($model, $key, $index, $column) {
                                 return $model->profile->post->name;
                         },
                         ],
                     ],
                     'searchClass' => 'app\models\UserSearch'
                    ],
             ], 
    ];
    

    components配置如下

    <?php
    return 
        [
            'request' => [
                // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
                'cookieValidationKey' => 'Owod8SuyH0Syh2pjYY6LYGIGvKtQLHAt',
            ],
            'cache' => [
                'class' => 'yii\caching\FileCache',
            ],
            'user' => [
                'identityClass' => 'app\models\User',
                'enableAutoLogin' => true,
            ],
        
            'urlManager'=>[
                'enablePrettyUrl' => true,
                'showScriptName' => false,//index.php
                ],
        
            'errorHandler' => [
                'errorAction' => 'site/error',
            ],
                'mailer' => [
                    'class' => 'yii\swiftmailer\Mailer',
                    // send all mails to a file by default. You have to set
                    // 'useFileTransport' to false and configure a transport
                // for the mailer to send real emails.
                'useFileTransport' => true,
                ],
            'log' => [
                    'traceLevel' => YII_DEBUG ? 3 : 0,
                    'targets' => [
                        [
                            'class' => 'yii\log\FileTarget',
                            'levels' => ['error', 'warning'],
                    ],
                ],
                ],
                'db' => require(__DIR__ . '/db.php'),
                //权限管理
                'authManager' => [
                    'class' => 'yii\rbac\DbManager',
                    'itemTable' => '{{%auth_item}}',
                    'assignmentTable' => '{{%auth_assignment}}',
                    'itemChildTable' => '{{%auth_item_child}}',
                    "defaultRoles" => ["guest"],
            ],
            //样式管理
            'assetManager' => [
            'bundles' => [
                'dmstr\web\AdminLteAsset' => [
                    'skin' => 'skin-blue',
                ],
                ],
            ],
    
助理 等级规则
110/200
资料完整度
10/100
用户活跃度
0/100

Ta的关注

2

Ta的粉丝

3

Ta的访客

4