<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\AccountJobsListRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
#[ORM\Entity(repositoryClass: AccountJobsListRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['account_job:read']],
denormalizationContext: ['groups' => ['account_job:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(SearchFilter::class, properties: [
'name' => 'ipartial',
'account.id' => 'exact',
'status' => 'exact',
])]
class AccountJobsList
{
#[Groups(['account_job:write', 'account_job:read', 'account:read', 'agreements:read', 'user:read', 'job:read', 'worker:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['account_job:write', 'account_job:read', 'account:read', 'agreements:read', 'user:read', 'job:read', 'worker:read'])]
#[ORM\Column(length: 255)]
private ?string $name = null;
#[Groups(['account_job:write', 'account_job:read', 'account:read', 'agreements:read', 'user:read', 'job:read', 'worker:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $status = null;
#[Groups(['account_job:write', 'account_job:read', 'account:read', 'agreements:read', 'user:read', 'job:read', 'worker:read'])]
#[ORM\ManyToOne(inversedBy: 'accountJobsLists')]
private ?MediaObject $document = null;
#[Groups(['account_job:write', 'account_job:read', 'job:read', 'worker:read'])]
#[ORM\ManyToOne(inversedBy: 'accountJobsLists')]
private ?Accounts $account = null;
#[Groups(['account_job:write', 'account_job:read', 'account:read', 'agreements:read', 'user:read', 'job:read', 'worker:read'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEnd = null;
#[Groups(['account_job:write', 'account_job:read', 'account:read', 'agreements:read', 'user:read', 'worker:read'])]
#[ORM\ManyToMany(targetEntity: Jobs::class, mappedBy: 'AccountJobsList')]
private Collection $jobs;
#[Groups(['account_job:write', 'account_job:read', 'account:read', 'agreements:read', 'user:read', 'worker:read'])]
#[ORM\ManyToMany(targetEntity: JobsLib::class, mappedBy: 'accountJobsList')]
private Collection $jobsLibs;
public function __construct()
{
// $this->mediaObjects = new ArrayCollection();
$this->jobs = new ArrayCollection();
$this->jobsLibs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getDocument(): ?MediaObject
{
return $this->document;
}
public function setDocument(?MediaObject $document): self
{
$this->document = $document;
return $this;
}
public function getAccount(): ?Accounts
{
return $this->account;
}
public function setAccount(?Accounts $account): self
{
$this->account = $account;
return $this;
}
public function getDateEnd(): ?\DateTimeInterface
{
return $this->dateEnd;
}
public function setDateEnd(?\DateTimeInterface $dateEnd): self
{
$this->dateEnd = $dateEnd;
return $this;
}
/**
* @return Collection<int, Jobs>
*/
public function getJobs(): Collection
{
return $this->jobs;
}
public function addJob(Jobs $job): self
{
if (!$this->jobs->contains($job)) {
$this->jobs->add($job);
$job->addAccountJobsList($this);
}
return $this;
}
public function removeJob(Jobs $job): self
{
if ($this->jobs->removeElement($job)) {
$job->removeAccountJobsList($this);
}
return $this;
}
/**
* @return Collection<int, JobsLib>
*/
public function getJobsLibs(): Collection
{
return $this->jobsLibs;
}
public function addJobsLib(JobsLib $jobsLib): self
{
if (!$this->jobsLibs->contains($jobsLib)) {
$this->jobsLibs->add($jobsLib);
$jobsLib->addAccountJobsList($this);
}
return $this;
}
public function removeJobsLib(JobsLib $jobsLib): self
{
if ($this->jobsLibs->removeElement($jobsLib)) {
$jobsLib->removeAccountJobsList($this);
}
return $this;
}
}