feat: crowd lists audit, enum, factory, service and tests

Audit and complete the Crowd Lists module:
- Add CrowdListType enum (internal/external) with proper casts
- Create CrowdListService for business logic (add/remove person,
  max_persons enforcement, auto_approve, activity logging)
- Create CrowdListFactory with Dutch names and states
- Create AddPersonToCrowdListRequest form request
- Fix FormRequests to use Rule::enum instead of hardcoded strings
- Fix CrowdListResource to use enum->value and add is_full field
- Refactor controller to be thin (delegates to service)
- Add eager loading for crowdType and recipientCompany
- Write 18 comprehensive tests (CRUD, auth, edge cases)
- Update API.md with request/response documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 13:53:57 +02:00
parent 52ea74b63d
commit cae2242502
11 changed files with 786 additions and 28 deletions

View File

@@ -11,17 +11,22 @@ final class CrowdListResource extends JsonResource
{
public function toArray(Request $request): array
{
$personsCount = $this->whenCounted('persons');
return [
'id' => $this->id,
'event_id' => $this->event_id,
'crowd_type_id' => $this->crowd_type_id,
'name' => $this->name,
'type' => $this->type,
'type' => $this->type->value,
'recipient_company_id' => $this->recipient_company_id,
'auto_approve' => $this->auto_approve,
'max_persons' => $this->max_persons,
'is_full' => $this->max_persons !== null && isset($this->persons_count)
? $this->persons_count >= $this->max_persons
: false,
'created_at' => $this->created_at->toIso8601String(),
'persons_count' => $this->whenCounted('persons'),
'persons_count' => $personsCount,
];
}
}