/** * Creates a new Freelance model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Freelance(); if ($model->load(Yii::$app->request->post())) { $this->CreateDir($model->ref); //$model->covenant = $this->uploadSingleFile($model); $model->docs = $this->uploadMultipleFile($model); if ($model->save()) { Yii::$app->getSession()->setFlash('alert1', ['type' => 'success', 'duration' => 10000, 'icon' => 'fa fa-bus', 'message' => 'บันทึกข้อมูลเสร็จเรียบร้อย ผู้ขออนุญาต - ' . $model->fullname, 'title' => 'การบันทึกข้อมูล', 'positonY' => 'top', 'positonX' => 'right']); return $this->redirect(['view', 'id' => $model->id]); } } else { Yii::$app->getSession()->setFlash('alert2', ['type' => 'danger', 'duration' => 10000, 'icon' => 'fa fa-error', 'message' => 'เกิดข้อผิดพลาด บันทึกข้อมูลwไม่สำเร็จ', 'title' => 'การบันทึกข้อมูล', 'positonY' => 'top', 'positonX' => 'right']); $model->ref = substr(Yii::$app->getSecurity()->generateRandomString(), 10); } return $this->render('create', ['model' => $model, 'border_start' => [], 'border_out' => []]); }