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:
74
api/database/factories/CrowdListFactory.php
Normal file
74
api/database/factories/CrowdListFactory.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\CrowdListType;
|
||||
use App\Models\Company;
|
||||
use App\Models\CrowdList;
|
||||
use App\Models\CrowdType;
|
||||
use App\Models\Event;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<CrowdList> */
|
||||
final class CrowdListFactory extends Factory
|
||||
{
|
||||
private const INTERNAL_NAMES = [
|
||||
'VIP Gastenlijst',
|
||||
'Backstage Crew',
|
||||
'Barpersoneel',
|
||||
'Opbouw Team',
|
||||
'Afbouw Team',
|
||||
'Vrijwilligers Hoofdpodium',
|
||||
'Nachtploeg',
|
||||
'EHBO Team',
|
||||
'Parkeerteam',
|
||||
'Kassa Medewerkers',
|
||||
];
|
||||
|
||||
private const EXTERNAL_NAMES = [
|
||||
'Catering Medewerkers',
|
||||
'Beveiligingspersoneel',
|
||||
'Technische Crew',
|
||||
'Schoonmaakploeg',
|
||||
'Leveranciers Personeel',
|
||||
];
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'event_id' => Event::factory(),
|
||||
'crowd_type_id' => CrowdType::factory(),
|
||||
'name' => fake()->randomElement(self::INTERNAL_NAMES),
|
||||
'type' => CrowdListType::INTERNAL,
|
||||
'recipient_company_id' => null,
|
||||
'auto_approve' => false,
|
||||
'max_persons' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public function external(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'name' => fake()->randomElement(self::EXTERNAL_NAMES),
|
||||
'type' => CrowdListType::EXTERNAL,
|
||||
'recipient_company_id' => Company::factory(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function withAutoApprove(): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'auto_approve' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function withMaxPersons(int $max): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'max_persons' => $max,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user