Documentation Index
Fetch the complete documentation index at: https://mintlify.com/astrxnomo/tourify/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The reviews system in Tourify is polymorphic — the samereviews table stores ratings for both places and events using reviewable_type and reviewable_id columns. Each user can leave exactly one review per item, and re-submitting a review updates the existing one rather than creating a duplicate, thanks to updateOrCreate.
All review endpoints require authentication. Include the
Authorization: Bearer {your-token} header on every request.How upsert works
The backend uses Eloquent’supdateOrCreate to find or create a review keyed on (user_id, reviewable_id, reviewable_type). If the user has already reviewed the item, the rating and comment fields are updated in place.
ReviewController.php (excerpt)
Endpoints
POST /api/places//reviews
Submit or update a review for a place. The response always returns HTTP201 whether the review was created or updated.
Path parameter
The ID of the place to review.
An integer star rating between 1 and 5 (inclusive).
An optional written comment. Maximum 1 000 characters. Send
null or omit to leave no comment.POST /api/events//reviews
Submit or update a review for an event. Identical validation rules and response shape as the place review endpoint. Path parameterThe ID of the event to review.
An integer star rating between 1 and 5 (inclusive).
An optional written comment. Maximum 1 000 characters.
Average ratings
Review averages are computed on the server and surfaced in the list and detail responses for both places and events:| Endpoint | Rating field |
|---|---|
GET /api/places | average_rating (rounded to 1 decimal, results sorted by this value descending) |
GET /api/places/{place} | average_rating (arithmetic mean of all reviews.rating) |
GET /api/events/{event} | Not included as a top-level field, but the reviews array contains individual ratings |
average_rating: 0.0.
Frontend integration
TheuseReviewForm hook manages the star picker and comment input. It dispatches to the correct endpoint based on the type prop ("place" or "event"):
hooks/useReviewForm.js
PlaceDetailScreen.jsx (excerpt)
Validation reference
| Field | Rule |
|---|---|
rating | Required · Integer · Min: 1 · Max: 5 |
comment | Optional · String · Max: 1 000 characters |