Added reviews and Filament

This commit is contained in:
pacnpal
2025-02-25 21:28:57 -05:00
parent 64b0e90a27
commit 4e06f7313e
4 changed files with 443 additions and 30 deletions

View File

@@ -98,4 +98,37 @@ $review->moderate(ReviewStatus::APPROVED, Auth::id());
$reviews = $ride->reviews()->approved()->latest()->get();
// Get user's helpful votes
$votes = $user->helpfulVotes()->with('review')->get();
$votes = $user->helpfulVotes()->with('review')->get();
```
## Implementation Notes
### Review Model Implementation
The Review model has been implemented in `app/Models/Review.php` with the following features:
- Fillable properties for all required fields
- Proper type casting for enum values and timestamps
- All relationships defined as specified (ride, user, moderator, helpfulVotes)
- Query scopes for filtering by status and relationships
- Methods for moderation and helpful vote management
### HelpfulVote Model Implementation
The HelpfulVote model has been implemented in `app/Models/HelpfulVote.php` with:
- Minimal properties (review_id, user_id)
- Relationships to Review and User models
- Static toggle method for easy vote management
### Ride Model Enhancements
The Ride model has been enhanced with review-related functionality:
- Added reviews() and approvedReviews() relationships
- Implemented getAverageRatingAttribute() for easy access to average ratings
- Added getReviewCountAttribute() for counting approved reviews
- Created canBeReviewedBy() method to check if a user can review a ride
- Implemented addReview() method for creating new reviews
These implementations maintain feature parity with the Django implementation while leveraging Laravel's Eloquent ORM features.