/** * 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())) { $fileName = $model->company_name; $model->company_created_date = date('Y-m-d'); $model->file = UploadedFile::getInstance($model, 'file'); $model->file->saveAs('uploads/' . $fileName . '.' . $model->file->extension); $model->logo = 'uploads/' . $fileName . '.' . $model->file->extension; $model->save(); return $this->redirect(['view', 'id' => $model->company_id]); } else { return $this->renderAjax('create', ['model' => $model]); } }