modules/admin/controllers/ClientController.php
/**
     * Creates a new searchCarModel model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new searchCarModel model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new searchCarModel model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new ClientModel();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            if($model->validate()) {
                $model->images = UploadedFile::getInstance($model, 'images');
                if ($model->images) {
                    $image_name = 'images/avatars/' . $model->id. '.png';
                    $model->images->saveAs($image_name);
                }
            }
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
public function actionCreate ( ) { $ model = new ClientModel ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { if ( $ model -> validate ( ) ) { $ model -> images = UploadedFile :: getInstance ( $ model , 'images' ) ; if ( $ model -> images ) { $ image_name = 'images/avatars/' . $ model -> id . '.png' ; $ model -> images -> saveAs ( $ image_name ) ; } } return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } }
Creates a new searchCarModel model.
Creates a new searchCarModel model .