src/Entity/Report.php line 28

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Entity\Mapped\Entity;
  6. use App\Repository\ReportRepository;
  7. use DateTime;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. #[ORM\Entity(
  13.     repositoryClassReportRepository::class
  14. )]
  15. #[ORM\Table(
  16.     name'report'
  17. )]
  18. #[ApiResource(
  19.     collectionOperations: [],
  20.     itemOperations: [
  21.         'get'
  22.     ]
  23. )]
  24. class Report extends Entity
  25. {
  26.     #[ORM\Column(
  27.         name'name',
  28.         type'string',
  29.         length181,
  30.         nullabletrue
  31.     )]
  32.     #[Assert\NotBlank(
  33.         groups: ['action']
  34.     )]
  35.     #[Assert\Length(
  36.         max180,
  37.         groups: ['action']
  38.     )]
  39.     #[Groups([
  40.         'read'
  41.     ])]
  42.     private ?string $name null;
  43.     #[ORM\Column(
  44.         name'date',
  45.         type'datetime',
  46.         nullabletrue
  47.     )]
  48.     private ?DateTime $date null;
  49.     #[ORM\Column(
  50.         name'submission_date',
  51.         type'datetime',
  52.         nullabletrue
  53.     )]
  54.     private ?DateTime $submissionDate null;
  55.     #[ORM\Column(
  56.         name'status',
  57.         type'string',
  58.         length181,
  59.         nullabletrue
  60.     )]
  61.     #[Assert\NotBlank(
  62.         groups: ['action']
  63.     )]
  64.     #[Groups([
  65.         'read'
  66.     ])]
  67.     private ?string $status null;
  68.     #[ORM\ManyToOne(
  69.         targetEntityUser::class
  70.     )]
  71.     #[ORM\JoinColumn(
  72.         name'receiver'
  73.     )]
  74.     private ?User $receiver null;    
  75.     #[ORM\ManyToOne(
  76.         targetEntityProject::class,
  77.         inversedBy'reports'
  78.     )]
  79.     #[ORM\JoinColumn(
  80.         name'project'
  81.     )]
  82.     private ?Project $project null;
  83.     #[ORM\OneToMany(
  84.         mappedBy'report',
  85.         targetEntityItemDocumentReport::class,
  86.         cascade: ['persist''remove'],
  87.         fetch'EXTRA_LAZY',
  88.         orphanRemovaltrue
  89.     )]
  90.     private ?iterable $itemDocumentReport;
  91.     #[ORM\Column(
  92.         name'amount',
  93.         type'decimal',
  94.         precision20,
  95.         scale2,
  96.         nullabletrue
  97.     )]
  98.     private ?string $amount null;
  99.     public function __construct()
  100.     {
  101.         $this->itemDocumentReport = new ArrayCollection();
  102.     }
  103.     public function getName(): ?string
  104.     {
  105.         return $this->name;
  106.     }
  107.     public function setName(?string $name): self
  108.     {
  109.         $this->name $name;
  110.         return $this;
  111.     }
  112.     public function getDate(): ?DateTime
  113.     {
  114.         return $this->date;
  115.     }
  116.     public function setDate(?DateTime $date): self
  117.     {
  118.         $this->date $date;
  119.         return $this;
  120.     }
  121.     public function getSubmissionDate(): ?DateTime
  122.     {
  123.         return $this->submissionDate;
  124.     }
  125.     public function setSubmissionDate(?DateTime $date): self
  126.     {
  127.         $this->submissionDate $date;
  128.         return $this;
  129.     }
  130.     public function getStatus(): ?string
  131.     {
  132.         return $this->status;
  133.     }
  134.     public function setStatus(?string $status): self
  135.     {
  136.         $this->status $status;
  137.         return $this;
  138.     }
  139.     public function getReceiver(): ?User
  140.     {
  141.         return $this->receiver;
  142.     }
  143.     public function setReceiver(?User $receiver): self
  144.     {
  145.         $this->receiver $receiver;
  146.         return $this;
  147.     }
  148.     public function getItemDocumentReport(): ?iterable
  149.     {
  150.         return $this->itemDocumentReport;
  151.     }
  152.     public function getProject(): ?Project
  153.     {
  154.         return $this->project;
  155.     }
  156.     public function setProject(?Project $project): self
  157.     {
  158.         $this->project $project;
  159.         return $this;
  160.     }
  161.     public function addItemDocumentReport(ItemDocumentReport $itemDocumentReport): void
  162.     {
  163.         if ($this->itemDocumentReport->contains($itemDocumentReport)) {
  164.             return;
  165.         }
  166.         $this->itemDocumentReport[] = $itemDocumentReport;
  167.         $itemDocumentReport->setReport($this);
  168.     }
  169.     public function removeItemDocumentReport(ItemDocumentReport $itemDocumentReport): void
  170.     {
  171.         if (!$this->itemDocumentReport->contains($itemDocumentReport)) {
  172.             return;
  173.         }
  174.         $this->itemDocumentReport->removeElement($itemDocumentReport);
  175.         $itemDocumentReport->setReport(null);
  176.     }
  177.     public function getAmount(): ?string
  178.     {
  179.         return $this->amount;
  180.     }
  181.     public function setAmount(?string $amount): self
  182.     {
  183.         $this->amount $amount;
  184.         return $this;
  185.     }
  186. }