src/Containers/SettingSection/ListContainer/Entities/AgentEntity.php line 74

Open in your IDE?
  1. <?php
  2. namespace App\Containers\SettingSection\ListContainer\Entities;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Delete;
  5. use ApiPlatform\Metadata\Get;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Patch;
  8. use ApiPlatform\Metadata\Post;
  9. use ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  12. use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
  13. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Doctrine\DBAL\Types\Types;
  18. use Gedmo\Mapping\Annotation as Gedmo;
  19. use App\Containers\SettingSection\ListContainer\Data\Repositories\AgentRepository;
  20. use App\Containers\SettingSection\IndexContainer\Entities\TranslationEntity;
  21. use App\Ship\ApiPlatform\Filter\SimpleSearchFilter;
  22. #[ApiResource(
  23.     routePrefix'/list',
  24.     normalizationContext: ['groups' => 'read'],
  25.     operations: [
  26.         new Get(
  27.             uriTemplate'/agent/{id}',
  28.             requirements: ['id' => '\d+'],
  29.             security"is_granted('ROLE_ADMIN')"
  30.         ),
  31.         new Patch(
  32.             uriTemplate'/agent/{id}',
  33.             requirements: ['id' => '\d+'],
  34.             security"is_granted('ROLE_ADMIN')"
  35.         ),
  36.         new Delete(
  37.             uriTemplate'/agent/{id}',
  38.             requirements: ['id' => '\d+'],
  39.             security"is_granted('ROLE_ADMIN')"
  40.         ),
  41.         new Post(
  42.             uriTemplate'/agent',
  43.             security"is_granted('ROLE_ADMIN')"
  44.         ),
  45.         new GetCollection(
  46.             uriTemplate'/agent',
  47.             security"is_granted('ROLE_ADMIN')"
  48.         ),
  49.     ],
  50.     shortName'List_Agent'
  51. )]
  52. #[ApiFilter(SearchFilter::class, properties: [
  53.     'id' => 'exact',
  54.     'name' => 'partial',
  55.     'code' => 'partial',
  56.     'docNum' => 'partial',
  57.     'jobType' => 'exact',
  58. ])]
  59. #[ApiFilter(NumericFilter::class, properties: ['id'])]
  60. #[ApiFilter(BooleanFilter::class, properties: ['isDefault'])]
  61. #[ApiFilter(RangeFilter::class, properties: ['id''kv'])]
  62. #[ApiFilter(OrderFilter::class)]
  63. #[ApiFilter(filterClassSimpleSearchFilter::class, properties: [
  64.     'name',
  65.     'code',
  66.     'docNum',
  67. ])]
  68. #[ORM\Entity(repositoryClassAgentRepository::class)]
  69. #[ORM\Table(name'`list_agent`')]
  70. #[Gedmo\TranslationEntity(class: TranslationEntity::class)]
  71. class AgentEntity
  72. {
  73.     #[ORM\Id]
  74.     #[ORM\GeneratedValue]
  75.     #[ORM\Column(typeTypes::INTEGER)]
  76.     #[Groups(['read'])]
  77.     private ?int $id null;
  78.     #[ORM\Column(typeTypes::STRINGlength255nullablefalse)]
  79.     #[Gedmo\Translatable]
  80.     #[Groups(['read'])]
  81.     private string $name;
  82.     #[ORM\Column(typeTypes::STRINGlength255nullablefalse)]
  83.     #[Gedmo\Translatable]
  84.     #[Groups(['read'])]
  85.     private string $code;
  86.     #[ORM\Column(typeTypes::STRINGlength255nullablefalse)]
  87.     #[Gedmo\Translatable]
  88.     #[Groups(['read'])]
  89.     private string $docNum;
  90.     #[ORM\ManyToOne(targetEntityAgentJobTypeEntity::class)]
  91.     #[ORM\JoinColumn(name'job_type_id'referencedColumnName'id'nullablefalse)]
  92.     #[Groups(['read'])]
  93.     private AgentJobTypeEntity $jobType;
  94.     #[ORM\Column(typeTypes::FLOATscale2nullablefalse)]
  95.     #[Groups(['read'])]
  96.     private float $kv;
  97.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  98.     #[Groups(['read'])]
  99.     private bool $isDefault false;
  100.     #[Gedmo\Timestampable(on'create')]
  101.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  102.     protected $createdAt;
  103.     #[Gedmo\Timestampable(on'update')]
  104.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  105.     protected $updatedAt;
  106.     /**
  107.      * Used locale to override Translation listener`s locale
  108.      * this is not a mapped field of entity metadata, just a simple property
  109.      */
  110.     #[Gedmo\Locale]
  111.     private $locale;
  112.     public function getId(): ?int
  113.     {
  114.         return $this->id;
  115.     }
  116.     public function getName()
  117.     {
  118.         return $this->name;
  119.     }
  120.     public function setName(string $name)
  121.     {
  122.         $this->name $name;
  123.         return $this;
  124.     }
  125.     public function getCode()
  126.     {
  127.         return $this->code;
  128.     }
  129.     public function setCode(string $code)
  130.     {
  131.         $this->code $code;
  132.         return $this;
  133.     }
  134.     public function getDocNum()
  135.     {
  136.         return $this->docNum;
  137.     }
  138.     public function setDocNum(string $docNum)
  139.     {
  140.         $this->docNum $docNum;
  141.         return $this;
  142.     }
  143.     public function getJobType()
  144.     {
  145.         return $this->jobType;
  146.     }
  147.     public function setJobType(AgentJobTypeEntity $jobType)
  148.     {
  149.         $this->jobType $jobType;
  150.         return $this;
  151.     }
  152.     public function getKv()
  153.     {
  154.         return $this->kv;
  155.     }
  156.     public function setKv($kv)
  157.     {
  158.         $this->kv $kv;
  159.         return $this;
  160.     }
  161.     public function getIsDefault()
  162.     {
  163.         return $this->isDefault;
  164.     }
  165.     public function setIsDefault($isDefault)
  166.     {
  167.         $this->isDefault $isDefault;
  168.         return $this;
  169.     }
  170.     public function setTranslatableLocale($locale)
  171.     {
  172.         $this->locale $locale;
  173.     }
  174. }