$reviews = PortaTourReview::where('tour_id', $tourId) ->where('is_approved', true) ->with('user:id,name,avatar') ->orderBy('created_at', 'desc') ->paginate(10); // Aggregate rating breakdown $stats = [ 'average_rating' => PortaTourReview::where('tour_id', $tourId) ->where('is_approved', true) ->avg('rating'), 'total_reviews' => $reviews->total(), 'rating_counts' => PortaTourReview::where('tour_id', $tourId) ->where('is_approved', true) ->selectRaw('rating, count(*) as count') ->groupBy('rating') ->pluck('count', 'rating') ];
class PortaTourReview extends Model
public function markHelpful($userId)
<div className="write-review"> <h3>Write your review</h3> <StarRating rating=newReview.rating onChange=(r) => setNewReview(...newReview, rating: r) /> <input placeholder="Review title" value=newReview.title onChange=e => setNewReview(...newReview, title: e.target.value) /> <textarea placeholder="Share your experience..." value=newReview.comment onChange=e => setNewReview(...newReview, comment: e.target.value) /> <button onClick=submitReview>Submit Review</button> </div> </div> ); ; portatour reviews
public function user()
protected $table = 'portatour_reviews'; protected $fillable = [ 'tour_id', 'user_id', 'booking_id', 'rating', 'title', 'comment', 'images', 'replies', 'is_verified_purchase', 'is_approved', 'helpful_count', 'reported_count' ]; $reviews = PortaTourReview::where('tour_id'
// POST /api/tours/tourId/reviews public function store(Request $request, $tourId) integer API Endpoint: Get Reviews for a Tour (with sorting/filtering) // GET /api/tours/tourId/reviews public function index($tourId) count(*) as count') ->