src/Entity/ModePayement.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  6. use App\Repository\ModePayementRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. /**
  13.  * @Vich\Uploadable
  14.  */
  15. #[ORM\Entity(repositoryClassModePayementRepository::class)]
  16. #[ApiFilter(BooleanFilter::class, properties: ['isBack'])]
  17. #[ApiResource(
  18.     iri'http://schema.org/modePayement',
  19.     normalizationContext:['groups' => ['mode_payement:read']],
  20.     denormalizationContext: ['groups' => ['mode_payement:write']],
  21.     collectionOperations: [
  22.         'get',
  23.         'post' => [
  24.             'input_formats' => [
  25.                 'multipart' => ['multipart/form-data'],
  26.             ],
  27.         ],
  28.     ],
  29. )]
  30. class ModePayement
  31. {
  32.     #[ORM\Id]
  33.     #[ORM\GeneratedValue]
  34.     #[ORM\Column(type'integer')]
  35.     #[Groups(['reservation:read','mode_payement:read','payement:read','TypeModePayement:read'])]
  36.     private $id;
  37.     #[ORM\Column(type'string'length50)]
  38.     #[Assert\NotBlank]
  39.     #[Assert\NotNull]
  40.     #[Groups(['mode_payement:write','mode_payement:read','reservation:read','payement:read','TypeModePayement:read'])]
  41.     private $label;
  42.     #[ORM\Column(type'string'length255)]
  43.     #[Groups(['mode_payement:read','TypeModePayement:read'])]
  44.     private $image;
  45.     /**
  46.      * @Vich\UploadableField(mapping="mode_payement", fileNameProperty="image")
  47.      */
  48.     #[Groups(['mode_payement:write'])]
  49.     #[Assert\NotBlank]
  50.     #[Assert\NotNull]
  51.     public ?File $file null;
  52.     #[ORM\Column(type'boolean')]
  53.     #[Assert\NotBlank]
  54.     #[Assert\NotNull]
  55.     #[Groups(['mode_payement:write','mode_payement:read'])]
  56.     private $isActive;
  57.     #[Groups(['mode_payement:read'])]
  58.     public $url;
  59.     #[ORM\Column(type'boolean'nullabletrue)]
  60.     private $isBack false;
  61.     #[ORM\ManyToOne(targetEntityTypeModePayement::class, inversedBy'modePayements')]
  62.     #[ORM\JoinColumn(nullablefalse)]
  63.     private $typeModePayement;
  64.     public function getId(): ?int
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getLabel(): ?string
  69.     {
  70.         return $this->label;
  71.     }
  72.     public function setLabel(string $label): self
  73.     {
  74.         $this->label $label;
  75.         return $this;
  76.     }
  77.     public function getImage(): ?string
  78.     {
  79.         return $this->image;
  80.     }
  81.     public function setImage(string $image): self
  82.     {
  83.         $this->image $image;
  84.         return $this;
  85.     }
  86.     public function isIsActive(): ?bool
  87.     {
  88.         return $this->isActive;
  89.     }
  90.     public function setIsActive(bool $isActive): self
  91.     {
  92.         $this->isActive $isActive;
  93.         return $this;
  94.     }
  95.     public function isIsBack(): ?bool
  96.     {
  97.         return $this->isBack;
  98.     }
  99.     public function setIsBack(?bool $isBack): self
  100.     {
  101.         $this->isBack $isBack;
  102.         return $this;
  103.     }
  104.     public function getTypeModePayement(): ?TypeModePayement
  105.     {
  106.         return $this->typeModePayement;
  107.     }
  108.     public function setTypeModePayement(?TypeModePayement $typeModePayement): self
  109.     {
  110.         $this->typeModePayement $typeModePayement;
  111.         return $this;
  112.     }
  113. }