I have a quick question about the redirect.
I was trying below code:
// Controller
public function actionDelete($id){
$model = $this->findModel($id);
$this->checkPermission($model);
$model->delete();
}
public function checkPermission($model) {
if(!Yii::$app->user->can('admin')){
Yii::$app->session->setFlash('warning', Yii::t('app', 'You do not have permission to perform this action.'));
return $this->redirect(['controller/view', 'id' => $model->id]);
}
}
when user without “admin” permission triggers delete action, it redirect as given in checkPermission function and also shows message but then it also deletes the object. Which means right after checkPermission redirect, it still continues executing $model->delete(); is this expected behaviour ??