I’m still trying to fully gasp the proper MVC design. When I generate models and controllers with Gii, certain code placement doesn’t make sense to me. For instance, generating a Controller will create accessRules method
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
This makes sense, we have a controller and it directs views which information is appropriate to whom. However, glancing at the models, I see attributeLabels
public function attributeLabels()
{
return array(
'id' => 'ID',
'name' => 'Name',
'description' => 'Description',
'create_time' => 'Create Time',
'create_user_id' => 'Create User',
'update_time' => 'Update Time',
'update_user_id' => 'Update User',
);
}
why is this inside a model and not a part of a controller? I thought models are for calculations and database interaction and controllers are all about what and how things should be displayed.