src/Entity/Job.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\JobRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=JobRepository::class)
  9.  */
  10. class Job
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="text")
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="job")
  24.      */
  25.     private $user;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="jobs")
  28.      * @ORM\JoinColumn(nullable=true)
  29.      */
  30.     private $company;
  31.     public function __construct()
  32.     {
  33.         $this->user = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getName(): ?string
  40.     {
  41.         return $this->name;
  42.     }
  43.     public function setName(string $name): self
  44.     {
  45.         $this->name $name;
  46.         return $this;
  47.     }
  48.     /**
  49.      * @return Collection|User[]
  50.      */
  51.     public function getUser(): Collection
  52.     {
  53.         return $this->user;
  54.     }
  55.     public function addUser(User $user): self
  56.     {
  57.         if (!$this->user->contains($user)) {
  58.             $this->user[] = $user;
  59.             $user->setJob($this);
  60.         }
  61.         return $this;
  62.     }
  63.     public function removeUser(User $user): self
  64.     {
  65.         if ($this->user->removeElement($user)) {
  66.             // set the owning side to null (unless already changed)
  67.             if ($user->getJob() === $this) {
  68.                 $user->setJob(null);
  69.             }
  70.         }
  71.         return $this;
  72.     }
  73.     public function getCompany(): ?Company
  74.     {
  75.         return $this->company;
  76.     }
  77.     public function setCompany(?Company $company): self
  78.     {
  79.         $this->company $company;
  80.         return $this;
  81.     }
  82. }