That's such a great idea.
Also I think it's worth noting that EloquentCollection can be specialized on a model basis like this:
class User extends Model { public function newCollection(array $models = []) { return new UserCollection($models); } } class UserCollection extends Illuminate\Database\Eloquent\Collection { public function admins(): self { return $this->filter($user => $user->isAdmin()); } }
So you can do
User::all()->admins();
(this example is purposefully oversimplified and in that specific case, one would better use scope...)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That's such a great idea.
Also I think it's worth noting that EloquentCollection can be specialized on a model basis like this:
So you can do
(this example is purposefully oversimplified and in that specific case, one would better use scope...)