src/Entity/Commission.php line 47

Open in your IDE?
  1. <?php
  2. // @deprecated
  3. declare(strict_types=1);
  4. namespace App\Entity;
  5. use ApiPlatform\Core\Annotation\ApiProperty;
  6. use ApiPlatform\Core\Annotation\ApiResource;
  7. use App\Trait\TimestampableEntity;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Ramsey\Uuid\Uuid;
  12. use Ramsey\Uuid\UuidInterface;
  13. /**
  14.  * Represents a commission related to a transaction.
  15.  *
  16.  * @see https://schema.org/Thing
  17.  */
  18. #[ORM\Entity]
  19. #[ApiResource(
  20.     iri'Commission',
  21.     itemOperations: [
  22.         'get' => ['normalization_context' => ['groups' => 'commission:item:get''enable_max_depth' => true]],
  23.         'put' => [
  24.             'normalization_context' => ['groups' => 'commission:item:put''enable_max_depth' => true],
  25.             'denormalization_context' => ['groups' => 'commission:item:put''enable_max_depth' => true],
  26.         ],
  27.         'delete' => [],
  28.     ],
  29.     collectionOperations: [
  30.         'get' => [
  31.             'normalization_context' => [
  32.                 'groups' => ['commission:collection:get''createdAt'],
  33.                 'enable_max_depth' => true,
  34.             ],
  35.         ],
  36.         'post' => [
  37.             'normalization_context' => ['groups' => 'commission:collection:post''enable_max_depth' => true],
  38.             'denormalization_context' => ['groups' => 'commission:collection:post''enable_max_depth' => true],
  39.         ],
  40.     ],
  41. )]
  42. class Commission
  43. {
  44.     use TimestampableEntity;
  45.     
  46.     #[ORM\Id]
  47.     #[ORM\GeneratedValue(strategy'NONE')]
  48.     #[ORM\Column(type'uuid'uniquetrue)]
  49.     #[ApiProperty(iri'https://schema.org/identifier')]
  50.     private ?UuidInterface $id null;
  51.     /**
  52.      * The type of the commission.
  53.      */
  54.     #[ORM\Column(type'string'nullablefalse)]
  55.     #[ApiProperty(iri'https://schema.org/commissionType')]
  56.     #[Assert\NotBlank]
  57.     #[Assert\Type('string')]
  58.     #[Groups(['commission:collection:get''commission:collection:post''commission:item:get''commission:item:put'])]
  59.     private ?string $commissionType null;
  60.     /**
  61.      * The percentage value of the commission.
  62.      */
  63.     #[ORM\Column(type'float'nullablefalse)]
  64.     #[ApiProperty(iri'https://schema.org/percentage')]
  65.     #[Assert\NotBlank]
  66.     #[Assert\Type('float')]
  67.     #[Groups(['commission:collection:get''commission:collection:post''commission:item:get''commission:item:put'])]
  68.     private ?float $percentage 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 setCommissionType(?string $commissionType): void
  78.     {
  79.         $this->commissionType $commissionType;
  80.     }
  81.     public function getCommissionType(): ?string
  82.     {
  83.         return $this->commissionType;
  84.     }
  85.     public function setPercentage(?float $percentage): void
  86.     {
  87.         $this->percentage $percentage;
  88.     }
  89.     public function getPercentage(): ?float
  90.     {
  91.         return $this->percentage;
  92.     }
  93. }