backend/controllers/BranchesController.php
/**
     * Creates a new Branches model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Branches model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Branches model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        if(Yii::$app->user->can('create-branch')){
            $model = new Branches();
            if ($model->load(Yii::$app->request->post())) {
                $model->branch_created_date = date('Y-m-d h:m:s');
                if($model->save()){
                    $message='success';
                }else{
                    $message='failer';
                }
                return $message;
            } else {
                return $this->renderAjax('create', [
                    'model' => $model,
                ]);
            }   
        }else{
            throw new ForbiddenHttpException; 
        }
    }
public function actionCreate ( ) { if ( Yii :: $ app -> user -> can ( 'create-branch' ) ) { $ model = new Branches ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> branch_created_date = date ( 'Y-m-d h:m:s' ) ; if ( $ model -> save ( ) ) { $ message = 'success' ; } else { $ message = 'failer' ; } return $ message ; } else { return $ this -> renderAjax ( 'create' , [ 'model' => $ model , ] ) ; } } else { throw new ForbiddenHttpException ; } }
Creates a new Branches model.
Creates a new Branches model .
//return $this->redirect(['view', 'id' => $model->branch_id]);