/** * Creates a new Event model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Event(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } return $this->render('create', ['model' => $model, 'users' => $this->getUsers(), 'typeEvents' => $this->getTypeEvents(), 'events' => $this->getEvents(), 'defaultEvent' => $this->getDefaultEvent()]); }
public function actionCreate() { $model = new Event(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionCreate() { $model = new Event(); if ($model->load(Yii::$app->request->post())) { $model->save(); //var_dump($model->getErrors()); die; } return $this->render('create', array('model' => $model)); }
/** * Creates a new Event model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Event(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'zal' => Zal::find()->asArray()->orderBy('name_zal')->all(), 'client' => Client::find()->asArray()->orderBy('name_client')->all(), 'users' => Users::find()->asArray()->where(['status' => 10])->orderBy('username')->all()]); } }
/** * Creates a new Event model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($date) { if (Yii::$app->user->can('admin')) { $model = new Event(); $model->created_date = $date; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index', 'id' => $model->id]); } else { return $this->renderAjax('create', ['model' => $model]); } } }
/** * Save event data in the database * * @param array $data * @throws \Exception */ public function save(array $data) { // Check event type if (!$this->hasValidEventType($data)) { throw new \Exception(\Yii::t("app", "Event has a invalid type: Should not be recorded.")); } // Prepare the data for the model validation $eventData = ['Event' => $data]; // New Event Model $eventModel = new Event(); // Populate Event Model and Save (with validation) if (!$eventModel->load($eventData) || !$eventModel->save()) { throw new \Exception(Yii::t("app", "Error saving Event Model")); } }
/** * Creates a new Event model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($date) { $model = new Event(); $model->user_id = Yii::$app->user->id; $model->date = $date; if ($model->load(Yii::$app->request->post())) { //var_dump($model); $model->shared_with = implode(',', $model->shared_with); if ($model->save()) { Yii::$app->notification->notify($model->title, $model, $model->user, Yii::$app->controller->id, $model->shared_with); } return $this->redirect(['view', 'id' => $model->id]); } elseif (Yii::$app->request->isAjax) { return $this->renderAjax('_form', ['model' => $model]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Event model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (\Yii::$app->user->isGuest) { return $this->redirect('/site/denied/'); } $user = \Yii::$app->user->identity; if (!$user->admin && count($user->organisations) == 0) { return $this->redirect('/site/denied/'); } $model = new Event(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }