src/Entity/ItemDocumentReport.php line 41

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Annotation\ApiSubresource;
  6. use App\Repository\ItemDocumentReportRepository;
  7. use DateTime;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(
  12.     repositoryClassItemDocumentReportRepository::class
  13. )]
  14. #[ORM\Table(
  15.     name'item_document_report'
  16. )]
  17. #[ApiResource(
  18.     collectionOperations: [
  19.         'post' => [
  20.             'validation_groups' => [
  21.                 'create'
  22.             ]
  23.         ]
  24.     ],
  25.     itemOperations: [
  26.         'get',
  27.         'delete'
  28.     ],
  29.     attributes: [
  30.         'normalization_context' => [
  31.             'groups' => [
  32.                 'read'
  33.             ]
  34.         ]
  35.     ]
  36. )]
  37. class ItemDocumentReport
  38. {
  39.     #[ORM\Id]
  40.     #[ORM\GeneratedValue]
  41.     #[ORM\Column(
  42.         type'integer'
  43.     )]
  44.     private ?int $id null;
  45.     #[ORM\Column(
  46.         name'date_created',
  47.         type'datetime',
  48.         nullabletrue
  49.     )]
  50.     private ?DateTime $dateCreated null;
  51.     #[ORM\Column(
  52.         name'date_changed',
  53.         type'datetime',
  54.         nullabletrue
  55.     )]
  56.     private ?DateTime $dateChanged null;
  57.     #[ORM\ManyToOne(
  58.         targetEntityUser::class,
  59.         cascade: ['persist']
  60.     )]
  61.     #[ORM\JoinColumn(
  62.         name'user_created'
  63.     )]
  64.     private ?User $userCreated null;
  65.     #[ORM\ManyToOne(
  66.         targetEntityUser::class,
  67.         cascade: ['persist']
  68.     )]
  69.     #[ORM\JoinColumn(
  70.         name'user_changed'
  71.     )]
  72.     private ?User $userChanged null;
  73.     #[ORM\Column(
  74.         name'active',
  75.         type'boolean',
  76.         options: ['default' => true]
  77.     )]
  78.     private bool $active true;
  79.     #[ORM\ManyToOne(
  80.         targetEntityItemDocument::class,
  81.         cascade: ['persist'],
  82.         inversedBy'reports'
  83.     )]
  84.     #[ORM\JoinColumn(
  85.         name'item_document',
  86.         onDelete'CASCADE'
  87.     )]
  88.     #[Assert\NotBlank(
  89.         groups: ['create']
  90.     )]
  91.     #[Groups(['read'])]
  92.     private ?ItemDocument $itemDocument null;
  93.     #[ORM\ManyToOne(
  94.         targetEntityReport::class,
  95.         cascade: ['persist'],
  96.         inversedBy'itemDocumentReport'
  97.     )]
  98.     #[ORM\JoinColumn(
  99.         name'report',
  100.         onDelete'CASCADE'
  101.     )]
  102.     #[Assert\NotBlank(
  103.         groups: ['create']
  104.     )]
  105.     #[Groups(['read''create'])]
  106.     #[ApiSubresource]
  107.     private ?Report $report null;
  108.     public function getId(): ?int
  109.     {
  110.         return $this->id;
  111.     }
  112.     public function setId($id): self
  113.     {
  114.         $this->id $id;
  115.         return $this;
  116.     }
  117.     public function getDateCreated(): ?DateTime
  118.     {
  119.         return $this->dateCreated;
  120.     }
  121.     public function setDateCreated(?DateTime $dateCreated): self
  122.     {
  123.         $this->dateCreated $dateCreated;
  124.         return $this;
  125.     }
  126.     public function getDateChanged(): ?DateTime
  127.     {
  128.         return $this->dateChanged;
  129.     }
  130.     public function setDateChanged(?DateTime $dateChanged): self
  131.     {
  132.         $this->dateChanged $dateChanged;
  133.         return $this;
  134.     }
  135.     public function getUserCreated(): ?User
  136.     {
  137.         return $this->userCreated;
  138.     }
  139.     public function setUserCreated(?User $userCreated): self
  140.     {
  141.         $this->userCreated $userCreated;
  142.         return $this;
  143.     }
  144.     public function getUserChanged(): ?User
  145.     {
  146.         return $this->userChanged;
  147.     }
  148.     public function setUserChanged(?User $userChanged): self
  149.     {
  150.         $this->userChanged $userChanged;
  151.         return $this;
  152.     }
  153.     public function isActive(): bool
  154.     {
  155.         return $this->active;
  156.     }
  157.     public function setActive(bool $active): void
  158.     {
  159.         $this->active $active;
  160.     }
  161.     public function getItemDocument(): ?ItemDocument
  162.     {
  163.         return $this->itemDocument;
  164.     }
  165.     public function setItemDocument(?ItemDocument $itemDocument): self
  166.     {
  167.         $this->itemDocument $itemDocument;
  168.         return $this;
  169.     }
  170.     public function getReport(): ?Report
  171.     {
  172.         return $this->report;
  173.     }
  174.     public function setReport(?Report $report): self
  175.     {
  176.         $this->report $report;
  177.         return $this;
  178.     }
  179. }