<?php
namespace App\Entity;
use App\Repository\JobRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=JobRepository::class)
*/
class Job
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="text")
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="job")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="jobs")
* @ORM\JoinColumn(nullable=true)
*/
private $company;
public function __construct()
{
$this->user = 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;
}
/**
* @return Collection|User[]
*/
public function getUser(): Collection
{
return $this->user;
}
public function addUser(User $user): self
{
if (!$this->user->contains($user)) {
$this->user[] = $user;
$user->setJob($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->user->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getJob() === $this) {
$user->setJob(null);
}
}
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
}