frontend/controllers/CompanyController.php
/**
     * Creates a new Company model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Company model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Company model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new Company();
        if ($model->load(Yii::$app->request->post())) {
            $model->hero_id = Yii::$app->user->identity->hero_id;
            $model->status = Company::STATUS_ACTIVE;
            $model->balance = 1000;
            try {
                if (!$model->save()) {
                    throw new Exception('Failed to save model: ' . VarDumper::dumpAsString($model));
                }
                Yii::$app->session->setFlash('success', 'Sikeres művelet!');
            } catch (Exception $e) {
                Yii::error($e);
                Yii::$app->session->setFlash('error', 'Belső hiba történt. Kérjük próbálja újra később!');
            }
            return $this->redirect(['view', 'id' => $model->id]);
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
public function actionCreate ( ) { $ model = new Company ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> hero_id = Yii :: $ app -> user -> identity -> hero_id ; $ model -> status = Company :: STATUS_ACTIVE ; $ model -> balance = 1000 ; try { if ( ! $ model -> save ( ) ) { throw new Exception ( 'Failed to save model: ' . VarDumper :: dumpAsString ( $ model ) ) ; } Yii :: $ app -> session -> setFlash ( 'success' , 'Sikeres művelet!') ; } catch ( Exception $ e ) { Yii :: error ( $ e ) ; Yii :: $ app -> session -> setFlash ( 'error' , 'Belső hiba történt. Kérjük próbálja újra később!'); } return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; }
Creates a new Company model.
Creates a new Company model .