src/Entity/SexualOrientation.php line 22

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\OrderFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Repository\SexualOrientationRepository")
  13.  * @ORM\HasLifecycleCallbacks()
  14.  */
  15. #[ApiResource(collectionOperations: ['get''post'], itemOperations: ['get''put'])]
  16. #[ApiFilter(PropertyFilter::class)]
  17. #[ApiFilter(SearchFilter::class, properties: ['id''name' => 'partial'])]
  18. #[ApiFilter(OrderFilter::class, properties: ['id''name'], arguments: ['orderParameterName' => 'order'])]
  19. class SexualOrientation
  20. {
  21.     /**
  22.      * @ORM\Id()
  23.      * @ORM\GeneratedValue()
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $id;
  27.     /**
  28.      * @ORM\Column(type="string", length=128)
  29.      * @Assert\NotBlank()
  30.      * @Assert\Length(max=128)
  31.      */
  32.     private $name;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(type="string", length=128)
  37.      * @Gedmo\Slug(fields={"name"})
  38.      */
  39.     private $slug;
  40.     /**
  41.      * @var bool
  42.      *
  43.      * @ORM\Column(type="boolean")
  44.      * @Assert\Type(type="boolean")
  45.      */
  46.     private $other;
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getName(): ?string
  52.     {
  53.         return $this->name;
  54.     }
  55.     public function setName(string $name): self
  56.     {
  57.         $this->name $name;
  58.         return $this;
  59.     }
  60.     public function __toString(): string
  61.     {
  62.         return $this->getName();
  63.     }
  64.     public function getOther(): ?bool
  65.     {
  66.         return $this->other;
  67.     }
  68.     public function setOther(bool $other): self
  69.     {
  70.         $this->other $other;
  71.         return $this;
  72.     }
  73.     public function getSlug(): ?string
  74.     {
  75.         return $this->slug;
  76.     }
  77.     public function setSlug(string $slug): self
  78.     {
  79.         $this->slug $slug;
  80.         return $this;
  81.     }
  82. }