src/Containers/CrmSection/TaskContainer/Entities/TaskEntity.php line 95

Open in your IDE?
  1. <?php
  2. namespace App\Containers\CrmSection\TaskContainer\Entities;
  3. use ApiPlatform\Metadata\GraphQl\Mutation;
  4. use ApiPlatform\Metadata\GraphQl\Query;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Delete;
  7. use ApiPlatform\Metadata\Get;
  8. use ApiPlatform\Metadata\GetCollection;
  9. use ApiPlatform\Metadata\Patch;
  10. use ApiPlatform\Metadata\Put;
  11. use ApiPlatform\Metadata\Post;
  12. use ApiPlatform\Metadata\ApiFilter;
  13. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  15. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  16. use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
  17. use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
  18. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  19. use ApiPlatform\Metadata\ApiProperty;
  20. use App\Containers\CompanySection\EmployeeContainer\Entities\EmployeeEntity;
  21. use App\Containers\CrmSection\TaskContainer\Data\Repositories\TaskRepository;
  22. use App\Containers\CrmSection\ContractContainer\Entities\ContractEntity;
  23. use App\Containers\CrmSection\ClientContainer\Entities\ClientEntity;
  24. use App\Containers\SettingSection\ListContainer\Entities\StatusEntity;
  25. use App\Containers\SettingSection\ListContainer\Entities\TaskTypeEntity;
  26. use Doctrine\ORM\Mapping as ORM;
  27. use Doctrine\DBAL\Types\Types;
  28. use Gedmo\Mapping\Annotation as Gedmo;
  29. use Symfony\Component\Serializer\Annotation\Groups;
  30. use Symfony\Component\Serializer\Annotation\MaxDepth;
  31. use Symfony\Component\Serializer\Annotation\Context;
  32. use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
  33. #[ORM\Entity(repositoryClassTaskRepository::class)]
  34. #[ORM\Table(name'`crm_tasks`')]
  35. #[ApiResource(
  36.     routePrefix'/crm',
  37.     operations: [
  38.         new GetCollection(
  39.             uriTemplate'/tasks',
  40.             openapiContext: [
  41.                 "summary" => ""
  42.             ]
  43.         ),
  44.         new Get(
  45.             uriTemplate'/tasks/{id}',
  46.             openapiContext: [
  47.                 "summary" => ""
  48.             ]
  49.         ),
  50.         new Post(
  51.             uriTemplate'/tasks',
  52.             openapiContext: [
  53.                 "summary" => ""
  54.             ]
  55.         ),
  56.         new Patch(
  57.             uriTemplate'/tasks/{id}',
  58.             openapiContext: [
  59.                 "summary" => ""
  60.             ]
  61.         ),
  62.         new Put(
  63.             uriTemplate'/tasks/{id}',
  64.             openapiContext: [
  65.                 "summary" => ""
  66.             ]
  67.         ),
  68.         new Delete(
  69.             uriTemplate'/tasks/{id}',
  70.             openapiContext: [
  71.                 "summary" => ""
  72.             ]
  73.         )
  74.     ],
  75.     normalizationContext: ['groups' => ['read'], 'enable_max_depth' => true],
  76.     security"is_granted('ROLE_ADMIN') or is_granted('ROLE_READONLY')",
  77.     shortName'CRM_Tasks'
  78. )]
  79. #[ApiFilter(SearchFilter::class, properties: [
  80.     'id' => 'exact'
  81.     'title' => 'partial',
  82.     'manager' => 'exact',
  83.     'responsible' => 'exact',
  84.     'material' => 'exact',
  85.     'status' => 'exact',
  86.     'client' => 'exact',
  87.     'contract' => 'exact',
  88.     'type' => 'exact'
  89. ])]
  90. #[ApiFilter(DateFilter::class, properties: ['dateDeadline''dateCompletion'])]
  91. #[ApiFilter(OrderFilter::class)]
  92. class TaskEntity
  93. {
  94.     #[ORM\Id]
  95.     #[ORM\GeneratedValue]
  96.     #[ORM\Column(typeTypes::INTEGER)]
  97.     #[Groups(['read'])]
  98.     private ?int $id null;
  99.     // Заголовок
  100.     #[ORM\Column(typeTypes::STRINGlength255nullablefalse)]
  101.     #[Groups(['read'])]
  102.     private string $title;
  103.     // Клиент
  104.     #[ORM\ManyToOne(targetEntityClientEntity::class)]
  105.     #[ORM\JoinColumn(name'client_id'referencedColumnName'id'nullabletrue)]
  106.     #[Groups(['read'])]
  107.     #[MaxDepth(1)]
  108.     private ?ClientEntity $client null;
  109.     // Договор
  110.     #[ORM\ManyToOne(targetEntityContractEntity::class)]
  111.     #[ORM\JoinColumn(name'contract_id'referencedColumnName'id'nullabletrue)]
  112.     #[Groups(['read'])]
  113.     #[MaxDepth(1)]
  114.     private ?ContractEntity $contract null;
  115.     // Дата крайнего срока
  116.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullabletrue)]
  117.     #[Context(
  118.         normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s'],
  119.         denormalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
  120.     )]
  121.     #[Groups(['read'])]
  122.     private ?\DateTimeInterface $dateDeadline null;
  123.     // Статус
  124.     #[ORM\ManyToOne(targetEntityStatusEntity::class)]
  125.     #[ORM\JoinColumn(name'status_id'referencedColumnName'id'nullabletrue)]
  126.     #[Groups(['read'])]
  127.     #[MaxDepth(2)]
  128.     private ?StatusEntity $status null;
  129.     // Тип задачи
  130.     #[ORM\ManyToOne(targetEntityTaskTypeEntity::class)]
  131.     #[ORM\JoinColumn(name'type_id'referencedColumnName'id'nullabletrue)]
  132.     #[Groups(['read'])]
  133.     #[MaxDepth(2)]
  134.     private ?TaskTypeEntity $type null;
  135.     // Постановщик
  136.     #[ORM\ManyToOne(targetEntityEmployeeEntity::class)]
  137.     #[ORM\JoinColumn(name'manager_id'referencedColumnName'id'nullabletrue)]
  138.     #[Groups(['read'])]
  139.     #[ApiProperty(pushtrue)]
  140.     #[MaxDepth(2)]
  141.     private ?EmployeeEntity $manager null;
  142.     // Ответственный
  143.     #[ORM\ManyToOne(targetEntityEmployeeEntity::class)]
  144.     #[ORM\JoinColumn(name'responsible_id'referencedColumnName'id'nullabletrue)]
  145.     #[Groups(['read'])]
  146.     #[MaxDepth(2)]
  147.     private ?EmployeeEntity $responsible null;
  148.     // Описание
  149.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  150.     #[Groups(['read'])]
  151.     private ?string $description null;
  152.     // Дата завершения
  153.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullabletrue)]
  154.     #[Context(
  155.         normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s'],
  156.         denormalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
  157.     )]
  158.     #[Groups(['read'])]
  159.     private ?\DateTimeInterface $dateCompletion null;
  160.     #[Gedmo\Timestampable(on'create')]
  161.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  162.     protected $createdAt;
  163.     #[Gedmo\Timestampable(on'update')]
  164.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  165.     protected $updatedAt;
  166.     
  167.     public function getId()
  168.     {
  169.         return $this->id;
  170.     }
  171.     public function getTitle()
  172.     {
  173.         return $this->title;
  174.     }
  175.     public function setTitle($title)
  176.     {
  177.         $this->title $title;
  178.         return $this;
  179.     }
  180.     public function getContract()
  181.     {
  182.         return $this->contract;
  183.     }
  184.     public function setContract($contract)
  185.     {
  186.         $this->contract $contract;
  187.         return $this;
  188.     }
  189.     public function getClient()
  190.     {
  191.         return $this->client;
  192.     }
  193.     public function setClient($client)
  194.     {
  195.         $this->client $client;
  196.         return $this;
  197.     }
  198.     public function getDateDeadline()
  199.     {
  200.         return $this->dateDeadline;
  201.     }
  202.     public function setDateDeadline(\DateTimeImmutable|null $date)
  203.     {
  204.         $this->dateDeadline $date;
  205.         return $this;
  206.     }
  207.     public function getStatus()
  208.     {
  209.         return $this->status;
  210.     }
  211.     public function setStatus($status)
  212.     {
  213.         $this->status $status;
  214.         return $this;
  215.     }
  216.     public function getType()
  217.     {
  218.         return $this->type;
  219.     }
  220.     public function setType($type)
  221.     {
  222.         $this->type $type;
  223.         return $this;
  224.     }
  225.     public function getManager()
  226.     {
  227.         return $this->manager;
  228.     }
  229.     public function setManager($manager)
  230.     {
  231.         $this->manager $manager;
  232.         return $this;
  233.     }
  234.     public function getResponsible()
  235.     {
  236.         return $this->responsible;
  237.     }
  238.     public function setResponsible($responsible)
  239.     {
  240.         $this->responsible $responsible;
  241.         return $this;
  242.     }
  243.     public function getDescription()
  244.     {
  245.         return $this->description;
  246.     }
  247.     public function setDescription(?string $description)
  248.     {
  249.         $this->description $description;
  250.         return $this;
  251.     }
  252.     public function getDateCompletion()
  253.     {
  254.         return $this->dateCompletion;
  255.     }
  256.     public function setDateCompletion(\DateTimeImmutable|null $date)
  257.     {
  258.         $this->dateCompletion $date;
  259.         return $this;
  260.     }
  261. }