feat: crowd types management UI with create/edit/deactivate

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 11:15:51 +02:00
parent d37a45b028
commit 169a078a92
6 changed files with 511 additions and 10 deletions

View File

@@ -20,7 +20,10 @@ final class CrowdTypeController extends Controller
{
Gate::authorize('viewAny', [CrowdType::class, $organisation]);
$crowdTypes = $organisation->crowdTypes()->where('is_active', true)->get();
$crowdTypes = $organisation->crowdTypes()
->orderByDesc('is_active')
->orderBy('name')
->get();
return CrowdTypeResource::collection($crowdTypes);
}
@@ -47,11 +50,7 @@ final class CrowdTypeController extends Controller
{
Gate::authorize('delete', [$crowdType, $organisation]);
if ($crowdType->persons()->exists()) {
$crowdType->update(['is_active' => false]);
} else {
$crowdType->delete();
}
$crowdType->update(['is_active' => false]);
return response()->json(null, 204);
}

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Http\Requests\Api\V1;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
final class StoreCrowdTypeRequest extends FormRequest
{
@@ -17,7 +18,12 @@ final class StoreCrowdTypeRequest extends FormRequest
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:100'],
'name' => [
'required',
'string',
'max:100',
Rule::unique('crowd_types')->where('organisation_id', $this->route('organisation')->id),
],
'system_type' => ['required', 'in:CREW,GUEST,ARTIST,VOLUNTEER,PRESS,PARTNER,SUPPLIER'],
'color' => ['required', 'regex:/^#[0-9A-Fa-f]{6}$/'],
'icon' => ['nullable', 'string', 'max:50'],