我有一個請假申請表hod只能查看推薦的應用程序。其他教授查看所有推薦應用程序。我有一個單一的數據庫表休閒休假。它有一個場推薦我想如果要推薦的推薦場然後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),
]);
}
在哪裏我的變化,如果變化是可能在哪裏我把條件
有什麼錯誤? –