MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / customCollection

Method customCollection

examples/laravel/app/Demo.php:116–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 ────────────────────────────────

Callers

nothing calls this directly

Calls 5

whereMethod · 0.80
topRatedMethod · 0.80
averageRatingMethod · 0.80
getMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected