src/Entity/Benefit.php line 21

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 Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\BenefitRepository")
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. #[ApiResource]
  15. #[ApiFilter(PropertyFilter::class)]
  16. #[ApiFilter(SearchFilter::class, properties: ['id''name' => 'partial'])]
  17. #[ApiFilter(OrderFilter::class, properties: ['id''name'], arguments: ['orderParameterName' => 'order'])]
  18. class Benefit
  19. {
  20.     /**
  21.      * @ORM\Id()
  22.      * @ORM\GeneratedValue()
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var string
  28.      *
  29.      * @ORM\Column(name="name", type="string", length=128)
  30.      * @Assert\NotBlank()
  31.      * @Assert\Length(max="128")
  32.      */
  33.     private $name;
  34.     /**
  35.      * @return string
  36.      */
  37.     public function __toString()
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): self
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54. }