src/Domain/Entity/PersonPromoCode.php line 33

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Domain\Entity;
  4. use ApiPlatform\Metadata\ApiProperty;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Delete;
  7. use ApiPlatform\Metadata\Get;
  8. use ApiPlatform\Metadata\GetCollection;
  9. use ApiPlatform\Metadata\Post;
  10. use ApiPlatform\Metadata\Put;
  11. use DateTime;
  12. use Gedmo\Timestampable\Traits\Timestampable;
  13. /**
  14.  * Class PromoCode
  15.  *
  16.  * @package App\Domain\Entity
  17.  */
  18. #[ApiResource(
  19.     operations            : [
  20.         new Delete(security"is_granted('ROLE_ADMIN')"),
  21.         new Get(security"is_granted('ROLE_ADMIN')"),
  22.         new GetCollection(security"is_granted('ROLE_ADMIN')"),
  23.         new Post(security"is_granted('ROLE_ADMIN')"),
  24.         new Put(security"is_granted('ROLE_ADMIN')"),
  25.     ],
  26.     normalizationContext  : ['groups' => ['person_promo_code_read']],
  27.     denormalizationContext: ['groups' => ['person_promo_code_write']]
  28. )]
  29. class PersonPromoCode
  30. {
  31.     use Timestampable;
  32.     #[ApiProperty(identifiertrue)]
  33.     public $id;
  34.     /**
  35.      * @param PromoCode $promoCode
  36.      * @param Person    $person
  37.      * @param DateTime  $start 
  38.      * @param DateTime  $end
  39.      */
  40.     public function __construct(
  41.         public PromoCode $promoCode,
  42.         public Person $person,
  43.         public DateTime $start,
  44.         public DateTime $end,
  45.     ) {}
  46.     public function getCreatedAt()
  47.     {
  48.         return $this->createdAt;
  49.     }
  50. }