src/Containers/CrmSection/EquipmentContainer/Entities/DamageEntity.php line 69

Open in your IDE?
  1. <?php
  2. namespace App\Containers\CrmSection\EquipmentContainer\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\Put;
  9. use ApiPlatform\Metadata\Post;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  13. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Doctrine\DBAL\Types\Types;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use Symfony\Component\Serializer\Annotation\MaxDepth;
  20. use App\Containers\CrmSection\EquipmentContainer\Data\Repositories\DamageRepository;
  21. use App\Containers\CrmSection\EquipmentContainer\Entities\ApplicationEntity;
  22. use App\Ship\ApiPlatform\Filter\SimpleSearchFilter;
  23. /** 
  24.  * Повреждения
  25. */
  26. #[ApiResource(
  27.     routePrefix'/crm',
  28.     normalizationContext: [
  29.         'groups' => 'read',
  30.         'enable_max_depth' => true
  31.     ],
  32.     operations: [
  33.         new Get(
  34.             uriTemplate'/application_damages/{id}'requirements: ['id' => '\d+'],
  35.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_INSTALLER') or is_granted('ROLE_READONLY')"
  36.         ),
  37.         new Patch(
  38.             uriTemplate'/application_damages/{id}'requirements: ['id' => '\d+'],
  39.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_INSTALLER')"
  40.         ),
  41.         // new Put(
  42.         //     uriTemplate: '/application_damages/{id}', requirements: ['id' => '\d+'],
  43.         //     security: "is_granted('ROLE_ADMIN')"
  44.         // ),
  45.         new Delete(
  46.             uriTemplate'/application_damages/{id}'requirements: ['id' => '\d+'],
  47.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_INSTALLER')"
  48.         ),
  49.         new Post(
  50.             uriTemplate'/application_damages',
  51.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_INSTALLER')"
  52.         ),
  53.         new GetCollection(
  54.             uriTemplate'/application_damages',
  55.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_INSTALLER') or is_granted('ROLE_READONLY')"
  56.         ),
  57.     ],
  58.     shortName'CRM_Equipments'
  59. )]
  60. #[ApiFilter(SearchFilter::class, properties: ['id' => 'exact''application' => 'exact''externalCode' => 'partial''placeDamage' => 'exact'])]
  61. #[ApiFilter(NumericFilter::class, properties: ['id'])]
  62. #[ApiFilter(RangeFilter::class, properties: ['id'])]
  63. #[ApiFilter(OrderFilter::class)]
  64. #[ORM\Entity(repositoryClassDamageRepository::class)]
  65. #[ORM\Table(name'`crm_equipments_damages`')]
  66. class DamageEntity
  67. {   
  68.     #[ORM\Id]
  69.     #[ORM\GeneratedValue]
  70.     #[ORM\Column(typeTypes::INTEGER)]
  71.     #[Groups(['read'])]
  72.     private ?int $id null;
  73.     #[ORM\Column(typeTypes::STRINGlength255nullabletrueuniquetrue)]
  74.     #[Groups(['read'])]
  75.     private ?string $externalCode null;
  76.     // Заявка
  77.     #[ORM\ManyToOne(targetEntityApplicationEntity::class)]
  78.     #[ORM\JoinColumn(name'application_id'referencedColumnName'id'nullablefalse)]
  79.     #[Groups(['read'])]
  80.     #[MaxDepth(2)]
  81.     private ApplicationEntity $application;
  82.     // Место повреждения
  83.     #[ORM\Column(typeTypes::TEXTnullablefalse)]
  84.     #[Groups(['read'])]
  85.     private string $placeDamage;
  86.     // Описание повреждения
  87.     #[ORM\Column(typeTypes::TEXTnullablefalse)]
  88.     #[Groups(['read'])]
  89.     private string $descriptionDamage;
  90.     // Комментарий
  91.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  92.     #[Groups(['read'])]
  93.     private ?string $comment null;
  94.     // Сортировка
  95.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 500])]
  96.     #[Groups(['read'])]
  97.     private int $sorting 500;
  98.     #[Gedmo\Timestampable(on'create')]
  99.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  100.     protected $createdAt;
  101.     #[Gedmo\Timestampable(on'update')]
  102.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  103.     protected $updatedAt;
  104.     public function getId(): ?int
  105.     {
  106.         return $this->id;
  107.     }
  108.     public function setId($value)
  109.     {
  110.         $this->id $value;
  111.         return $this;
  112.     }
  113.     public function getExternalCode()
  114.     {
  115.         return $this->externalCode;
  116.     }
  117.     public function setExternalCode($code)
  118.     {
  119.         $this->externalCode $code;
  120.         return $this;
  121.     }
  122.     public function getApplication()
  123.     {
  124.         return $this->application;
  125.     }
  126.     public function setApplication($application)
  127.     {
  128.         $this->application $application;
  129.         return $this;
  130.     }
  131.     public function getPlaceDamage()
  132.     {
  133.         return $this->placeDamage;
  134.     }
  135.     public function setPlaceDamage($comment)
  136.     {
  137.         $this->placeDamage $comment;
  138.         return $this;
  139.     }
  140.     public function getDescriptionDamage()
  141.     {
  142.         return $this->descriptionDamage;
  143.     }
  144.     public function setDescriptionDamage($description)
  145.     {
  146.         $this->descriptionDamage $description;
  147.         return $this;
  148.     }
  149.     public function getComment()
  150.     {
  151.         return $this->comment;
  152.     }
  153.     public function setComment($comment)
  154.     {
  155.         $this->comment $comment;
  156.         return $this;
  157.     }
  158.     public function getSorting()
  159.     {
  160.         return $this->sorting;
  161.     }
  162.     public function setSorting($value)
  163.     {
  164.         $this->sorting $value;
  165.         return $this;
  166.     }
  167.     public function setCreatedAt(\DateTimeImmutable|null $date)
  168.     {
  169.         $this->createdAt $date;
  170.         return $this;
  171.     }
  172.     public function setUpdatedAt(\DateTimeImmutable|null $date)
  173.     {
  174.         $this->updatedAt $date;
  175.         return $this;
  176.     }
  177. }