public function randombadreview()
 {
     $reviewModel = new Review();
     $review = $reviewModel->getRandomBadReview(3);
     // we return a json
     return json_encode($review);
 }
 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);
 }
 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);
 }
Beispiel #4
0
 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;
 }
Beispiel #5
0
 protected function buildFromInput(Review $review, $input)
 {
     $verdict = $input->get('verdict');
     $productId = $input->get('product_id');
     $product = $this->findProduct($productId);
     if (!$product) {
         throw $this->createModelNotFoundException('Product', $productId);
     }
     $review->setVerdictFromBool($verdict);
     $review->setProduct($product);
     EntityManager::persist($review);
     EntityManager::flush();
     return $review;
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 4) as $index) {
         Review::create(['product_id' => 92, 'user_id' => $faker->numberBetween($min = 170, $max = 173), 'comment' => $faker->text(), 'stars' => $faker->numberBetween($min = 4.5, $max = 5.0)]);
     }
 }
 public function run()
 {
     // query
     $review = Review::find()->where(['=', 'review_moderation', 'yes'])->orderBy('id_review DESC')->limit(3)->all();
     //render view
     return $this->render('latest', ['review' => $review]);
 }
Beispiel #8
0
 /**
  * Finds the Review model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Review the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Review::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #9
0
 public static function getListByBlogId($blog_id, $p = 1, $pageSize = 30)
 {
     $blog_id = intval($blog_id);
     $query = Review::find()->where(['blog_id' => $blog_id]);
     $count = $query->count();
     $pagination = new Pagination(['defaultPageSize' => $pageSize, 'totalCount' => $count]);
     $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['time' => SORT_ASC])->asArray()->limit($pageSize)->all();
     return ['list' => $list];
 }
Beispiel #10
0
 public function afterSave($insert, $changedAttributes)
 {
     $part = $this->getPartFk()->one();
     $query = Review::find()->where(['part_fk' => $this->part_fk]);
     $sum = $query->sum('rating');
     $count = $query->count();
     $part->overal_rating = $sum / $count;
     $part->updateAttributes(['overal_rating']);
     parent::afterSave($insert, $changedAttributes);
 }
 /**
  * Displays a single Part model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $parameters = new ActiveDataProvider(['query' => $model->getParameters()]);
     if (!Yii::$app->user->isGuest) {
         $userReview = Review::find()->where(['user_fk' => Yii::$app->user->identity->user_id])->andWhere(['part_fk' => $model->part_id])->one();
         $partBuildPair = BuildPart::findOne(['part_fk' => $model['part_id'], 'build_guide_fk' => Yii::$app->session['build_id']]);
     } else {
         $userReview = NULL;
         $partBuildPair = NULL;
     }
     return $this->render('view', ['model' => $model, 'parameters' => $parameters, 'review' => $userReview, 'partBuildPair' => $partBuildPair]);
 }
 /**
  * Lists all your student Review models.
  * @return mixed
  */
 public function actionIndex()
 {
     // Show only your reviews
     // Now hardcoded user ID = 1 which is a student
     $student_ID = \Yii::$app->user->identity->getId();
     // Get the AVG score
     $avgScore = Review::find()->where(['receiver_id' => $student_ID])->average('score');
     Yii::trace($avgScore);
     // Get the reviews
     $query = Review::find()->where(['receiver_id' => $student_ID]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]);
     return $this->render('index', ['dataProvider' => $dataProvider, 'avgScore' => $avgScore]);
 }
Beispiel #13
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Review::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['review_id' => $this->review_id, 'patient_id' => $this->patient_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'subject', $this->subject])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'contact', $this->contact]);
     return $dataProvider;
 }
Beispiel #14
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Review::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['review_id' => $this->review_id, 'restaurant_id' => $this->restaurant_id, 'product_id' => $this->product_id]);
     $query->andFilterWhere(['like', 'review', $this->review]);
     return $dataProvider;
 }
Beispiel #15
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Review::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'writer_id' => $this->writer_id, 'receiver_id' => $this->receiver_id, 'vacancy_id' => $this->vacancy_id, 'is_anonymous' => $this->is_anonymous, 'score' => $this->score, 'creation_date' => $this->creation_date]);
     $query->andFilterWhere(['like', 'explanation', $this->explanation]);
     return $dataProvider;
 }
Beispiel #16
0
 public function actionReview()
 {
     $id = \Yii::$app->request->post('id');
     $session_name = 'blog_review_' . $id;
     if (!$this->defend($session_name)) {
         return $this->ajaxReturn('评论过于频繁,稍后尝试', false);
     }
     if (!Blog::allowReview($id)) {
         return $this->ajaxReturn('博客禁止评论', false);
     }
     $nickname = \Yii::$app->request->post('nickname');
     $content = \Yii::$app->request->post('content');
     if ($info = Review::add(['pid' => 0, 'blog_id' => $id, 'nickname' => $nickname, 'content' => $content], true)) {
         $review = ['nickname' => $info->nickname, 'content' => htmlspecialchars_decode($info->content), 'time' => $info->time, 'date' => date('y/m/d', $info->time)];
         return $this->ajaxReturn(['info' => $review]);
     } else {
         return $this->ajaxReturn(Review::getError(), false);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $review = \App\Models\Review::find($id);
     $review->delete();
     return redirect("reviews");
 }
Beispiel #18
0
 public function getReview()
 {
     return $this->hasMany(Review::className(), ['product_id' => 'product_id']);
 }
Beispiel #19
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getReviews()
 {
     return $this->hasMany(Review::className(), ['user_fk' => 'user_id']);
 }
Beispiel #20
0
<?php

use app\models\Review;
$commentList = Review::getListByBlogId($id);
?>
<div class="comment">
<div class="row">
<p class="col-lg-12">评论 ( <?php 
echo count($commentList['list']);
?>
 ) </p>
<form name="comment" action="/blog/review/" onsubmit="return false">
	<input type="hidden" name="id" value="<?php 
echo $id;
?>
">
	<div class="col-lg-3"><input placeholder="昵称" name="nickname" class="form-control" type="text"/></div>
	<div class="col-lg-12"><textarea placeholder="内容" name="content" class="form-control"></textarea></div>
	<div class="col-lg-10 tip">*注: 昵称只能填写中文,内容必须包含中文,HTML标签将自动过滤</div>
	<div class="col-lg-2 text-right">
		<span name="submit" class="btn btn-primary">发布</span>
	</div>
</form>
</div><!--/. form -->
	<div class="">
		<div class="comment-list">
<?php 
if ($commentList['list']) {
    foreach ($commentList['list'] as $key => $row) {
        if (\Yii::$app->controller->isSuper($row['uid'])) {
            ?>
 /**
  * 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]);
 }
Beispiel #22
0
 public function actionDeleteReview()
 {
     /*if(!Yii::$app->user->can('admin')){
           Yii::$app->session->setFlash('error','Нет доступа!');
           return $this->redirect('/');
       }*/
     $review = Review::find()->where(['id' => Yii::$app->request->get('id')])->one();
     $review->delete();
 }
Beispiel #23
0
 protected function findModel($id)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     if (($model = Review::find()->where(['review_id' => $id])->one()) !== null) {
         return $model;
     } else {
         echo json_encode(array('status' => 0, 'error_code' => Codes::$BAD_REQUEST, 'message' => StatusCodeMessage::$BAD_REQUEST), JSON_PRETTY_PRINT);
         exit;
         // throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #24
0
 public function getReviews()
 {
     return $this->hasMany(Review::className(), ['vacancy_id' => 'id']);
 }
Beispiel #25
0
 /**
  * Finds the Review model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Review the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $model = new Review();
     $model->scenario = Review::SCENARIO_READ;
     if (($model = Review::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #26
0
 /**
  * Get avg score
  */
 public function getReviewScore()
 {
     return round(Review::find()->where(['writer_id' => $this->getPrimaryKey()])->average('score'), 1, PHP_ROUND_HALF_UP);
 }
 /**
  * Get the logged in user's review of a product
  *
  * @param $productID
  *
  * @return mixed
  */
 public function retrieveUserReview($productID)
 {
     return Review::whereUserId($this->id)->Where('product_id', $productID)->get()->unique();
 }
Beispiel #28
0
@section('content')
            <section class="contbook">
                  <h1 id="maintext">Tell us what our service is</h1>
            </section>

            <div id="reviews">
                <div class="heading1"><h1>Add your review</h1><img src="{{asset('img/span.fw.png')}}" class="graf">
                    @if(Auth::check())
                    <a href="{{url('reviews/create')}}">Click here to add a review</a></div>
                    @else
                    <a href="{{url('login')}}">Click here to add a review</a></div>
                    @endif
                    <div class="main_review_wrap">
                    
                    <?php 
$reviews = \App\Models\Review::paginate(3);
$reviews->setPath("");
?>

                        @foreach($reviews as $review)
                                  
                           <div class="review">
                                <h2>{{$review->user->firstname}} {{$review->user->lastname}}<br><span>{{$review->created_at}}</span></h2>
                                    <p>{{$review->content}}</a></p><br>

                                    @if(Auth::check())
                                        @if(Auth::user()->admin == 1)
                                            {!! Form::open(["url"=>"reviews/".$review->id, "method"=>"delete"]) !!} 
                                            {!! Form::submit("Delete", array('class'=>'pure-button pure-button-primary')) !!}
                                            {!! Form::close() !!}
                                        @endif
 public function getSubReview($id)
 {
     $review = Review::find($id);
     if ($review) {
         $sub_reviews = $review->hasSubReviews;
         if ($sub_reviews) {
             foreach ($sub_reviews as $sub_review) {
                 $sub_review->mozier;
             }
             return $sub_reviews;
         }
     } else {
         return $this->notFoundResponse();
     }
 }
 public function one(Review $review)
 {
     return ['id' => $review->getId(), 'product' => (new ProductSerializer())->one($review->getProduct()), 'worth_it' => $this->verdictToHumanReadable($review->getVerdict())];
 }