/** * Creates a new Review model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Review(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id_review]); } else { return $this->render('create', ['model' => $model]); } }
public function store(Request $request) { $validation = Validator::make($request->all(), ['rating' => 'numeric|between:1,10', 'title' => 'required|min:5', 'description' => 'required|min:10', 'dvd_id' => 'required|integer']); if ($validation->fails()) { return redirect('/dvds/' . $request->input('dvd_id'))->withInput()->withErrors($validation); } $review = new Review(['rating' => $request->input('rating'), 'title' => $request->input('title'), 'description' => $request->input('description'), 'dvd_id' => $request->input('dvd_id')]); $review->save(); return redirect('/dvds/' . $request->input('dvd_id'))->with('success', true); }
/** * Creates a new Review model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($part) { $model = new Review(); $model->part_fk = $part; $model->user_fk = Yii::$app->user->identity->user_id; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['part/view', 'id' => $model->part_fk]); } else { return $this->render('create', ['model' => $model]); } }
public function add_review(Request $request) { $validation = Validator::make($request->all(), ['review_title' => 'required|min:5', 'review_rating' => 'required|numeric|min:1|max:10', 'review_description' => 'required|min:10', 'dvd_id' => 'required|integer']); $dvd_id = $request->input('dvd_id'); if ($validation->fails()) { return redirect("dvds/" . $dvd_id)->withInput()->withErrors($validation); } $review = new Review(['review_title' => $request->input('review_title'), 'review_rating' => $request->input('review_rating'), 'review_description' => $request->input('review_description'), 'dvd_id' => $request->input('dvd_id')]); $review->save(); return redirect("/dvds/" . $dvd_id)->with('success', true); }
/** * Creates a new Review model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (Yii::$app->user->isGuest || Yii::$app->user->identity->user_role != 4 && Yii::$app->user->identity->user_role != 3 && Yii::$app->user->identity->user_role != 2) { return $this->goHome(); } $model = new Review(['scenario' => Review::SCENARIO_CREATE]); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->review_id]); } else { return $this->render('create', ['model' => $model]); } }
public function save() { if ($this->validate()) { $model = new Review(); $model->patient_id = $this->patient->patient_id; $model->subject = $this->subject; $model->body = $this->body; $model->contact = $this->contact; return $model->save(); } return false; }
private function createAjax() { $data = Yii::$app->request->post(); $model = new Review(['scenario' => Review::SCENARIO_CREATE]); foreach ($data['Review'] as $key => $value) { $model->{$key} = $value; } if ($model->validate()) { return $model->save() ? true : ErrorHelper::errorsToString($model->errors); } else { return ErrorHelper::errorsToString($model->errors); } }
/** * Creates a new Review model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($vacancyId) { $model = new Review(); $vacancy = Vacancy::findOne($vacancyId); if ($vacancy === null) { throw new HttpException(404, "This vacancy the Students Assistent is working for is not found"); } $model->vacancy_id = $vacancyId; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Display item */ public function actionArticle() { // form $model = new ContactForm(); // id product $ware = $_GET['ware']; // get data review if ($model->load(Yii::$app->request->post())) { // get data form $reviewData = Yii::$app->request->post("ContactForm"); // get name and body $reviewName = $reviewData['name']; $reviewBody = $reviewData['body']; // get current date $reviewDate = date("Y") . '-' . date("m") . '-' . date("d"); // moderation $reviewModeration = 'no'; // insert review $review = new Review(['review_date' => $reviewDate, 'review_name' => $reviewName, 'product_id' => $ware, 'review' => $reviewBody, 'review_moderation' => $reviewModeration]); $review->save(); Yii::$app->session->setFlash('success', 'После успешной модерации отзыв будет опубликован.'); } // count review product $comment = Review::find()->where(['=', 'product_id', $ware])->andWhere(['=', 'review_moderation', 'yes'])->all(); $amount = count($comment); // find product $article = Product::find()->where(['=', 'id_product', $ware])->all(); // current section foreach ($article as $vlArticle) { $curSection = $vlArticle->section_id; } // find section $section = Section::find()->where(['=', 'id_section', $curSection])->all(); // current catalog foreach ($section as $vlSection) { $curCatalog = $vlSection->catalog_id; } // find catalog $catalog = Catalog::find()->where(['=', 'id_catalog', $curCatalog])->all(); return $this->render('article', ['article' => $article, 'section' => $section, 'catalog' => $catalog, 'model' => $model, 'amount' => $amount, 'comment' => $comment]); }
public function actionAddReview() { $c = new Review(); $c->user_id = Yii::$app->user->id; $c->review = Yii::$app->request->post('rev'); $c->create_at = time(); $c->save(); }
public function actionCreate() { $role = UserRoleDetector::getUserRole(); Yii::$app->response->format = Response::FORMAT_JSON; if ($role != 3 && $role != 4) { echo json_encode(array('status' => 0, 'error_code' => Codes::$UNAUTHORIZED, 'errors' => StatusCodeMessage::$UNAUTHORIZED), JSON_PRETTY_PRINT); } else { $params = $_REQUEST; $model = new Review(); $model->attributes = $params; if ($model->save()) { echo json_encode(array('status' => 1, 'code' => 200, 'data' => array_filter($model->attributes)), JSON_PRETTY_PRINT); } else { echo json_encode(array('status' => 0, 'error_code' => Codes::$BAD_REQUEST, 'errors' => $model->errors), JSON_PRETTY_PRINT); } } }