authorizeCurrentWorkspace( $request, 'createPost', 'Not authorized to manage labels.', ); if (! $workspace instanceof Workspace) { return $workspace; } $validated = $request->validate([ 'name' => ['required', 'string', 'max:255'], 'color' => ['required', 'string', 'max:7', 'regex:/^#[0-9A-Fa-f]{6}$/'], ]); $label = CreateLabel::execute($workspace, $validated); return Response::structured((new LabelResource($label))->resolve()); } public function schema(JsonSchema $schema): array { return [ 'name' => $schema->string()->required()->description('The label name.'), 'color' => $schema->string()->required()->description('Hex color code (e.g. #FF5733).'), ]; } }