feat : finalisation de l'étape 1 "Réception" (formulaire)

This commit is contained in:
2026-01-27 16:59:36 +01:00
parent 9ae073e69e
commit f901d52324
46 changed files with 1977 additions and 88 deletions

80
src/Entity/Supplier.php Normal file
View File

@@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
#[ORM\Entity]
#[ORM\Table(name: 'supplier')]
#[ApiResource(
operations: [
new Get(
requirements: ['id' => '\d+'],
normalizationContext: ['groups' => ['supplier:read']],
),
new GetCollection(
normalizationContext: ['groups' => ['supplier:read']],
),
],
security: "is_granted('ROLE_USER')",
)]
class Supplier
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['supplier:read', 'reception:read'])]
private ?int $id = null;
#[ORM\Column(length: 180)]
#[Groups(['supplier:read', 'reception:read'])]
private string $name = '';
/**
* @var Collection<int, Address>
*/
#[ORM\ManyToMany(targetEntity: Address::class, inversedBy: 'suppliers')]
#[ORM\JoinTable(name: 'supplier_address')]
#[Groups(['supplier:read'])]
#[ApiProperty(readableLink: true)]
private Collection $addresses;
public function __construct()
{
$this->addresses = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, Address>
*/
public function getAddresses(): Collection
{
return $this->addresses;
}
}