mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 08:11:10 -05:00
Added reviews and Filament
This commit is contained in:
@@ -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.
|
||||
Reference in New Issue
Block a user