'boolean', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function product(): BelongsTo { return $this->belongsTo(Product::class); } public function getDateAttribute(): string { return $this->created_at->format('d.m.Y'); } public function getIsFreshAttribute(): bool { return $this->created_at->gt(now()->subWeek()); } public function scopeApproved($query) { return $query->where('is_approved', true); } public function scopeByRating($query, $rating) { return $query->where('rating', $rating); } public function scopeHelpful($query) { return $query->orderBy('helpful_count', 'desc'); } public function scopeLatest($query) { return $query->orderBy('created_at', 'desc'); } public function scopeUserProduct($query, $userId, $productId) { return $query->where('user_id', $userId) ->where('product_id', $productId); } }