<?php
namespace App\Entity;
use App\Repository\SpecialityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SpecialityRepository::class)
*/
class Speciality
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="speciality")
*/
private $users;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="specialite")
*/
private $products;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $name_en;
public function __construct()
{
$this->users = new ArrayCollection();
$this->products = new ArrayCollection();
}
public function __toString()
{
return $this->getName();
}
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<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setSpeciality($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->getSpeciality() === $this) {
$user->setSpeciality(null);
}
}
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setSpecialite($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getSpecialite() === $this) {
$product->setSpecialite(null);
}
}
return $this;
}
public function getNameEn(): ?string
{
return $this->name_en;
}
public function setNameEn(?string $name_en): self
{
$this->name_en = $name_en;
return $this;
}
}