我有一个请假申请表,只能查看推荐的申请。其他教授查看所有申请推荐。我有一个数据库表休闲假。它有一个我想要的字段推荐如果建议推荐字段然后hod查看apllication不然,我该怎么办
this is my update code
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post())) {
$model->start_date = strtotime($model->start_date);
$model->start_date = date('Y-m-d',$model->start_date);
$model->end_date = strtotime($model->end_date);
$model->end_date = date('Y-m-d',$model->end_date);
$model->date_of_request = strtotime($model->date_of_request);
$model->date_of_request = date('Y-m-d',$model->date_of_request);
// $model->start_date = date_format($model->start_date,'Y-m-d');
if(!Yii::$app->user->isGuest && !Yii::$app->user->identity->username == 'hod' )
{
$model->recommendation = 'recommended';
}else if(Yii::$app->user->identity->username == 'hod'){
$model->status='sanctioned';
}
if($model->save()){
return $this->redirect(['view', 'id' => $model->id]);
}else{
return $this->render('create', [
'model' => $model,
]);
}
}
else {
return $this->render('create', [
'model' => $model,
//Yii::app()->user->setReturnUrl("casual-leaves/index");
]);
//new line
}
}
查看代码
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
我在哪里更改,如果我可以在条件
的情况下进行更改答案 0 :(得分:0)
如果您使用RBAC
组件,则可以为任何用户设置类型并设置条件。
然后,你可以这样做:
if(Yii::$app->user->isGuest){
//do something
}
else if(Yii::$app->authManager->checkAccess(Yii::$app->user->id, "hod")){
//do something
}
else{
//do something
}