()
| 114 | // ── Custom Eloquent Collections ───────────────────────────────────────── |
| 115 | |
| 116 | public function customCollection(): void |
| 117 | { |
| 118 | // Builder chain → custom collection via #[CollectedBy] |
| 119 | $reviews = Review::where('published', true)->get(); |
| 120 | $top = $reviews->topRated(); // custom method from ReviewCollection |
| 121 | $avg = $reviews->averageRating(); // custom method from ReviewCollection |
| 122 | $reviews->first(); // inherited — returns Review|null |
| 123 | echo count($top), $avg; |
| 124 | |
| 125 | // Relationship properties also use the custom collection |
| 126 | $review = new Review(); |
| 127 | $review->replies->topRated(); // HasMany<Review> → ReviewCollection |
| 128 | } |
| 129 | |
| 130 | |
| 131 | // ── Eloquent Closure Parameter Inference ──────────────────────────────── |
nothing calls this directly
no test coverage detected