Пример #1
0
 public function store(){
     $input=Input::get();
     unset($input['_token']);
     unset($input['submit']);
     Review::create($input);
     return Redirect::route('review_index');
 }
 public function run()
 {
     DB::table('reviews')->delete();
     Review::create(array('productId' => 1, 'stars' => 5, 'body' => 'I love this product!', 'author' => '*****@*****.**'));
     Review::create(array('productId' => 1, 'stars' => 3, 'body' => 'Not bad for the price.', 'author' => '*****@*****.**'));
     Review::create(array('productId' => 2, 'stars' => 1, 'body' => 'Horrible product!', 'author' => '*****@*****.**'));
     Review::create(array('productId' => 2, 'stars' => 2, 'body' => 'Needs more...', 'author' => '*****@*****.**'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     try {
         Review::create(array('productId' => Input::get('productId'), 'stars' => Input::get('stars'), 'body' => Input::get('body'), 'author' => Input::get('author')));
     } catch (Exception $e) {
         Log::error($e);
     }
     return Response::json(array('success' => true));
 }
Пример #4
0
 /**
  * Create an instance of Place by passing an array of properties.
  * This is mainly used by the GoogleAPI to convert it's raw
  * result data into a more usable collection of Places.
  *
  * @param string[] $args An array of properties to turn into a Place
  *
  * @return Place
  */
 public static function create(array $args)
 {
     $instance = new self();
     foreach ($args as $property => $value) {
         if (!in_array($property, self::$properties)) {
             continue;
         }
         if ($property == 'reviews') {
             foreach ($value as $review) {
                 $instance->reviews[] = Review::create($review);
             }
         } else {
             $instance->{$property} = $value;
         }
     }
     return $instance;
 }
Пример #5
0
<?php

require_once "../initialize.php";
$message = "";
if (isset($_POST['review']) && $_POST['review'] != "" && isset($_POST['rating']) && $_POST['rating'] != "" && isset($_POST['userid']) && $_POST['userid'] != "" && isset($_POST['itemid']) && $_POST['itemid'] != "" && isset($_POST['itemtype']) && $_POST['itemtype'] != "") {
    $review = new Review();
    $review->userid = $_POST['userid'];
    $review->itemid = $_POST['itemid'];
    $review->itemtype = $_POST['itemtype'];
    $review->review = $_POST['review'];
    $review->rating = $_POST['rating'];
    $review->pending = $_POST['pending'];
    $review->enabled = $_POST['enabled'];
    if (isset($_FILES['picture'])) {
        $file = new File($_FILES['picture']);
        $review->picture = $file->data;
    }
    $review->create();
    $log = new Log($session->userid, $clientip, "WEB", "CREATED REVIEW: " . $review->id);
    $log->create();
    $message .= "success";
} else {
    $message = "You have missed a required field.";
}
echo $message;
Пример #6
0
<?php

require_once '../core/init.php';
if (isset($_POST['comment'])) {
    $app_id = (int) $database->escape_value(htmlentities(trim($_POST['app_id'])));
    $name = $database->escape_value(htmlentities(trim($_POST['name'])));
    $rating = (int) $database->escape_value(htmlentities(trim($_POST['rating'])));
    $summary = $database->escape_value(htmlentities(trim($_POST['summary'])));
    $comment = $database->escape_value(htmlentities(trim($_POST['comment'])));
    $time_posted = time();
    $review = new Review();
    $review->app_id = $app_id;
    $review->user = $name;
    $review->summary = $summary;
    $review->message = $comment;
    $review->time_posted = $time_posted;
    if ($review->create()) {
        echo "success";
    } else {
        echo "failed";
    }
} else {
    echo "no request";
}
require_once "../../includes/initialize.php";
global $session;
if (!$session->is_logged_in()) {
    redirect_to("../../index.php");
}
if ($_POST['oper'] == 'add') {
    $object = new Review();
    $object->userid = $_POST['userid'];
    $object->itemid = $_POST['itemid'];
    $object->itemtype = $_POST['itemtype'];
    $object->review = $_POST['review'];
    $object->rating = $_POST['rating'];
    $object->pending = $_POST['pending'];
    $object->enabled = $_POST['enabled'];
    $object->create();
    $log = new Log($session->userid, $clientip, "WEB", "CREATED REVIEW: " . $_POST['id']);
    $log->create();
} else {
    if ($_POST['oper'] == 'edit') {
        $object = Review::get_by_id($_POST['id']);
        $object->userid = $_POST['userid'];
        $object->itemid = $_POST['itemid'];
        $object->itemtype = $_POST['itemtype'];
        $object->review = $_POST['review'];
        $object->rating = $_POST['rating'];
        $object->pending = $_POST['pending'];
        $object->enabled = $_POST['enabled'];
        $object->update();
        $log = new Log($session->userid, $clientip, "WEB", "UPDATED REVIEW: " . $_POST['id']);
        $log->create();
 try {
     $new_review = new Review();
     $restaurant = new Restaurant();
     if ($restaurant->find($restaurant_id)) {
         $original_rating = $restaurant->get_rating();
         $new_rating = $rate;
         $all_reviews = Review::get_all_reviews_by_restaurant($restaurant_id);
         // var_dump($all_reviews);
         if ($all_reviews) {
             $overall_rate = 0;
             while ($a_review = $all_reviews->fetch_row()) {
                 $overall_rate += $a_review[4];
             }
             $new_rating = ($overall_rate + $rate) / ($all_reviews->num_rows + 1);
         }
         $new_review->create($fields);
         $restaurant->update_rating($new_rating);
         $success = true;
         $message = 'Adding review complete! Your review will be attached to the restaurant page shortly.';
     }
 } catch (Exception $e) {
     $success = false;
     $message = $e->getMessage();
 }
 $return_result = array('success' => $success, 'message' => $message);
 echo json_encode($return_result);
 // //add review
 // $title = $POST['title'];
 // $content = $_POST['content'];
 // $rating = $_POST['rating'];
 // $date = date('Y-m-d');
Пример #9
0
 function post_review()
 {
     if (isset($_POST['comment'])) {
         $app_id = (int) $this->input->post('app_id', TRUE);
         $name = $this->input->post('name', TRUE);
         $rating = (int) $this->input->post('rating', TRUE);
         $summary = $this->input->post('summary', TRUE);
         $comment = $this->input->post('comment', TRUE);
         $time_posted = time();
         $review = new Review();
         $review->app_id = $app_id;
         $review->user = $name;
         $review->rating = $rating;
         $review->summary = $summary;
         $review->message = $comment;
         $review->time_posted = $time_posted;
         if ($review->create()) {
             echo "success";
         } else {
             echo "failed";
         }
     } else {
         echo "no request sent";
     }
 }
Пример #10
0
 public function create()
 {
     return Review::create($this->params);
 }
Пример #11
0
 public static function sendreview($input)
 {
     // var_dump(Request::segment(2)); die();
     if (Sentry::check()) {
         if ($input['to'] == Sentry::getUser()->email) {
             return Redirect::back()->with('info', 'You cannot send an inquiry to yourself!');
         } elseif ($input['subject'] == "") {
             return Redirect::back()->with('info', 'You have to fill in the body!');
         } else {
             $input['from'] = Sentry::getUser()->email;
             $input['score'] = 5;
             $review = Review::create($input);
             return Redirect::route('reviews.show', $review->id)->with('success', 'Review Successfully Sent!');
             // $reviews = Review::where('to', '=', $input['from']);
             // return Redirect::route('users.show', $review->id, compact('reviews')); //return Redirect::route('signin')
         }
     } else {
         //from the modal
         // if($input['subject'] == ""):
         // 	return Redirect::back()->with('info', 'You have to fill in the body!');
         // else:
         // 	$input['from'] = session_id();
         // 	$input['from'] = Sentry::getUser()->email;
         // 	$input['status'] = 'pending';
         // 	$review = Review::create($input);
         // endif;
         $message = 'You have to sign In to Submit a Review';
         // return Redirect::back()->with('success', $message);
         return Redirect::route('signin');
     }
 }
Пример #12
0
 public static function Create($review)
 {
     Review::create(array('value' => $review->value, 'product_id' => $review->product_id, 'account_id' => $review->account_id));
 }
    print_r($rsv->get_reservation_info());
    echo "<br>";
    echo $rsv->get_reservation_info_json();
    echo "<br>";
} catch (Exception $e) {
    $success = false;
    $message = $e->getMessage();
    echo "Find reservation Error: " . $message . "<br>";
}
echo ($success == true ? "SUCCESS" : "FAILURE") . "<br>";
$fields = array('user_id' => '1', 'restaurant_id' => '3', 'title' => 'Review Title', 'content' => 'Review content ABCD', 'rating' => '5');
echo "<br>Testing for creating a review: <br>";
$review_id = 0;
$review = new Review();
try {
    $review_id = $review->create($fields);
    $success = true;
    $message = 'New review creation is complete.<br>';
    echo $message;
} catch (Exception $e) {
    $success = false;
    $message = $e->getMessage();
    echo "Creating a new review Error: " . $message . "<br>";
}
echo ($success == true ? "SUCCESS" : "FAILURE") . "<br>";
try {
    echo "<br>Testing find review:<br>";
    print_r("If found review:" . $review->find($review_id) . "<br>");
    print_r($review->get_review_info());
    echo "<br>";
    echo $review->get_review_info_json();