controllers/CakesController.php
/**
     * Creates a new Cake model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Cake model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Cake model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        if(CakesCategory::getCategoryList() == null){
            return $this->redirect(['/cakes-category/create']);
        }
        $model = new Cake();
        $model->created_at = Yii::$app->formatter->asDatetime(time());
        $model->updated_at = Yii::$app->formatter->asDatetime(time());
        if ($model->load(Yii::$app->request->post())) {
            $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
            if($model->upload() && $model->save()){
                return $this->redirect(['index']);
            }
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
public function actionCreate ( ) { if ( CakesCategory :: getCategoryList ( ) == null ) { return $ this -> redirect ( [ '/cakes-category/create' ] ) ; } $ model = new Cake ( ) ; $ model -> created_at = Yii :: $ app -> formatter -> asDatetime ( time ( ) ) ; $ model -> updated_at = Yii :: $ app -> formatter -> asDatetime ( time ( ) ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> imageFile = UploadedFile :: getInstance ( $ model , 'imageFile' ) ; if ( $ model -> upload ( ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'index' ] ) ; } } return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; }
Creates a new Cake model.
Creates a new Cake model .