src/Entity/Gender.php line 30

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