<?php
namespace App\Entity;
use App\Repository\ContractRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(indexes={ @ORM\Index(name="idx_contract_module_id", columns={"module_id"}), @ORM\Index(name="idx_contract_program_id", columns={"program_id"}) })
* @ORM\Entity(repositoryClass=ContractRepository::class)
*/
class Contract extends BaseEntity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $code;
/**
* @ORM\ManyToOne(targetEntity=Module::class, inversedBy="contracts")
* @ORM\JoinColumn(name="module_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private $module;
/**
* @ORM\ManyToOne(targetEntity=Program::class, inversedBy="contracts")
* @ORM\JoinColumn(name="program_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
private $program;
/**
* @ORM\ManyToOne(targetEntity=Live::class, inversedBy="contracts")
*/
private $live;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="contract", fetch="EXTRA_LAZY")
*/
private $users;
/**
* @ORM\OneToMany(targetEntity=Target::class, mappedBy="contract", fetch="EXTRA_LAZY")
*/
private $targets;
public function __construct()
{
$this->users = new ArrayCollection();
$this->targets = 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 getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function getModule(): ?Module
{
return $this->module;
}
public function setModule(?Module $module): self
{
$this->module = $module;
return $this;
}
public function getProgram(): ?Program
{
return $this->program;
}
public function setProgram(?Program $program): self
{
$this->program = $program;
return $this;
}
public function getLive(): ?Live
{
return $this->live;
}
public function setLive(?Live $live): self
{
$this->live = $live;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setContract($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getContract() === $this) {
$user->setContract(null);
}
}
return $this;
}
/**
* @return Collection<int, Target>
*/
public function getTarges(): Collection
{
return $this->targets;
}
public function addTarget(Target $target): self
{
if (!$this->targets->contains($target)) {
$this->targets[] = $target;
$target->setContract($this);
}
return $this;
}
public function removeTarget(Target $target): self
{
if ($this->targets->removeElement($target)) {
// set the owning side to null (unless already changed)
if ($target->getContract() === $this) {
$target->setContract(null);
}
}
return $this;
}
}