feat(documents) : add DocumentType enum and type column on entity

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-23 15:09:49 +01:00
parent 2043e5b643
commit 342b0afdbb
2 changed files with 34 additions and 0 deletions

View File

@@ -12,9 +12,11 @@ use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Entity\Trait\CuidEntityTrait;
use App\Enum\DocumentType;
use App\Repository\DocumentRepository;
use App\State\DocumentUploadProcessor;
use DateTimeImmutable;
@@ -46,6 +48,7 @@ use Symfony\Component\Serializer\Attribute\Groups;
inputFormats: ['multipart' => ['multipart/form-data']],
),
new Put(security: "is_granted('ROLE_GESTIONNAIRE')"),
new Patch(security: "is_granted('ROLE_GESTIONNAIRE')"),
new Delete(security: "is_granted('ROLE_GESTIONNAIRE')"),
],
paginationClientItemsPerPage: true,
@@ -105,6 +108,10 @@ class Document
#[Groups(['document:list'])]
private ?Site $site = null;
#[ORM\Column(type: Types::STRING, length: 20, enumType: DocumentType::class)]
#[Groups(['document:list', 'document:read', 'composant:read', 'piece:read', 'product:read'])]
private DocumentType $type = DocumentType::DOCUMENTATION;
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')]
#[Groups(['document:list'])]
private DateTimeImmutable $createdAt;
@@ -237,4 +244,16 @@ class Document
return $this;
}
public function getType(): DocumentType
{
return $this->type;
}
public function setType(DocumentType $type): static
{
$this->type = $type;
return $this;
}
}

15
src/Enum/DocumentType.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Enum;
enum DocumentType: string
{
case DOCUMENTATION = 'documentation';
case DEVIS = 'devis';
case FACTURE = 'facture';
case PLAN = 'plan';
case PHOTO = 'photo';
case AUTRE = 'autre';
}