public function submitReview() { //Get the request from the submitted page $aRequest = \Request::all(); //Get the Session $aSession = \Session::all(); //GET RESTAURANT ID $aRestaurant = DB::table('restaurants')->where(array('username' => $aRequest['username']))->get(array("id_restaurant")); $oRestaurant = $aRestaurant[0]; $aReview['id_restaurant'] = $oRestaurant->id_restaurant; $aReview['id_user'] = $aSession['id_user']; $aReview['body'] = $aRequest['review']; $aReview['rating'] = $aRequest['rating']; $oImage = $aRequest['review-picture']; //Uplaod the pociture of the review $FullImagePath = Backend::uploadPhotos($oImage, 'review-picture'); $aReview['review_image'] = $FullImagePath; $aReview['date_created'] = Date('Y-m-d h:i:s'); //Insert the data into Reviews Table and get it's id $dReviewId = DB::table('reviews')->insertGetId($aReview); //Add Activity to it's table //save activity into the DB: Backend::addActivity($aSession['id_user'], 'review', $dReviewId); //Redirect the user to the restaurant's page. return redirect('/p/' . $aRequest['username']); }