/**
  * Creates a new Companies model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Companies();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->company_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Companies model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Companies();
     if (Yii::$app->request->isAjax && $model->load($_POST)) {
         Yii::$app->response->format = 'json';
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->company_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Companies model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Companies();
     if (Yii::$app->request->isAjax && $model->load($_POST)) {
         Yii::$app->response->format = 'json';
         return \yii\widgets\ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         //get the instance of the uploaded file
         $imageName = $model->company_name;
         $model->file = UploadedFile::getInstance($model, 'file');
         $model->file->saveAs('uploads/' . $imageName . '.' . $model->file->extension);
         // save the path in the db column
         $model->logo = 'uploads/' . $imageName . '.' . $model->file->extension;
         $model->save();
         return $this->redirect(['view', 'id' => $model->company_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }