src/Entity/ContractCargo.php line 46

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use App\Trait\TimestampableEntity;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Serializer\Annotation\MaxDepth;
  11. use Ramsey\Uuid\Uuid;
  12. use Ramsey\Uuid\UuidInterface;
  13. /**
  14.  * @see https://schema.org/Thing
  15.  *
  16.  * @author Jordi Fernandes Alves <jfadev@gmail.com>
  17.  */
  18. #[ORM\Entity]
  19. #[ApiResource(
  20.     iri'ContractCargo',
  21.     itemOperations: [
  22.         'get' => ['normalization_context' => ['groups' => 'contract_cargo:item:get''enable_max_depth' => true]],
  23.         'put' => [
  24.             'normalization_context' => ['groups' => 'contract_cargo:item:put''enable_max_depth' => true],
  25.             'denormalization_context' => ['groups' => 'contract_cargo:item:put''enable_max_depth' => true],
  26.         ],
  27.         'delete' => [],
  28.     ],
  29.     collectionOperations: [
  30.         'get' => [
  31.             'normalization_context' => [
  32.                 'groups' => ['contract_cargo:collection:get''createdAt'],
  33.                 'enable_max_depth' => true,
  34.             ],
  35.         ],
  36.         'post' => [
  37.             'normalization_context' => ['groups' => 'contract_cargo:collection:post''enable_max_depth' => true],
  38.             'denormalization_context' => ['groups' => 'contract_cargo:collection:post''enable_max_depth' => true],
  39.         ],
  40.     ],
  41. )]
  42. class ContractCargo
  43. {
  44.     use TimestampableEntity;
  45.     #[ORM\Id]
  46.     #[ORM\GeneratedValue(strategy'NONE')]
  47.     #[ORM\Column(type'uuid'uniquetrue)]
  48.     private ?UuidInterface $id null;
  49.     #[ORM\ManyToOne(targetEntity'App\Entity\Cargo'inversedBy'contractCargos')]
  50.     #[ORM\JoinColumn(nullabletrue)]
  51.     #[ApiProperty(iri'https://schema.org/Cargo')]
  52.     #[Groups(['contract_cargo:collection:get''contract_cargo:collection:post''contract_cargo:item:get''contract_cargo:item:put''contract:collection:post''contract:item:get''contract:item:put'])]
  53.     #[MaxDepth(1)]
  54.     private ?Cargo $cargo null;
  55.     #[ORM\Column(type'string'nullabletrue)]
  56.     #[ApiProperty(iri'https://schema.org/quantityM3')]
  57.     #[Groups(['contract_cargo:collection:get''contract_cargo:collection:post''contract_cargo:item:get''contract_cargo:item:put''contract:collection:post''contract:item:get''contract:item:put'])]
  58.     private ?string $quantityM3 null;
  59.     #[ORM\Column(type'string'nullabletrue)]
  60.     #[ApiProperty(iri'https://schema.org/quantityMT')]
  61.     #[Groups(['contract_cargo:collection:get''contract_cargo:collection:post''contract_cargo:item:get''contract_cargo:item:put''contract:collection:post''contract:item:get''contract:item:put'])]
  62.     private ?string $quantityMT null;
  63.     #[ORM\ManyToOne(targetEntity'App\Entity\Contract'inversedBy'cargoItems')]
  64.     #[ORM\JoinColumn(nullabletrue)]
  65.     #[ApiProperty(iri'https://schema.org/Contract')]
  66.     #[Groups(['contract_cargo:collection:get''contract_cargo:collection:post''contract_cargo:item:get''contract_cargo:item:put'])]
  67.     #[MaxDepth(1)]
  68.     private ?Contract $contract null;
  69.     public function __construct()
  70.     {
  71.         $this->id Uuid::uuid4();
  72.     }
  73.     public function getId(): ?UuidInterface
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function setCargo(?Cargo $cargo): void
  78.     {
  79.         $this->cargo $cargo;
  80.     }
  81.     public function getCargo(): ?Cargo
  82.     {
  83.         return $this->cargo;
  84.     }
  85.     public function setContract(?Contract $contract): void
  86.     {
  87.         $this->contract $contract;
  88.     }
  89.     public function getContract(): ?Contract
  90.     {
  91.         return $this->contract;
  92.     }
  93.     public function getQuantityM3(): ?string
  94.     {
  95.         return $this->quantityM3;
  96.     }
  97.     public function setQuantityM3(?string $quantityM3): void
  98.     {
  99.         $this->quantityM3 $quantityM3;
  100.     }
  101.     public function getQuantityMT(): ?string
  102.     {
  103.         return $this->quantityMT;
  104.     }
  105.     public function setQuantityMT(?string $quantityMT): void
  106.     {
  107.         $this->quantityMT $quantityMT;
  108.     }
  109. }