*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'name' => $this->name, 'slug' => $this->slug, 'description' => $this->description, 'public' => $this->public, 'members_count' => $this->whenCounted('members'), 'created_at' => $this->created_at?->toIso8601String(), 'updated_at' => $this->updated_at?->toIso8601String(), 'members' => $this->whenLoaded('members', fn (): array => $this->members ->map(fn (User $member): array => [ 'id' => $member->id, 'name' => $member->name, 'email' => $member->email, ]) ->all()), ]; } }