*/ public function handle(): Collection { return Group::get(); } public function asController(ActionRequest $request, ?Group $group = null): AnonymousResourceCollection { return GroupResource::collection( $request->has('all') ? Group::with('children')->get() : ($group ? $group->children()->withCount('children')->get() : Group::where('parent_id', null)->withCount('children')->get()) ); } }