src/Entity/Speciality.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SpecialityRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=SpecialityRepository::class)
  9.  */
  10. class Speciality
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="speciality")
  24.      */
  25.     private $users;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Product::class, mappedBy="specialite")
  28.      */
  29.     private $products;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $name_en;
  34.     public function __construct()
  35.     {
  36.         $this->users = new ArrayCollection();
  37.         $this->products = new ArrayCollection();
  38.     }
  39.     public function __toString()
  40.     {
  41.         return $this->getName();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(string $name): self
  52.     {
  53.         $this->name $name;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection<int, User>
  58.      */
  59.     public function getUsers(): Collection
  60.     {
  61.         return $this->users;
  62.     }
  63.     public function addUser(User $user): self
  64.     {
  65.         if (!$this->users->contains($user)) {
  66.             $this->users[] = $user;
  67.             $user->setSpeciality($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeUser(User $user): self
  72.     {
  73.         if ($this->users->removeElement($user)) {
  74.             // set the owning side to null (unless already changed)
  75.             if ($user->getSpeciality() === $this) {
  76.                 $user->setSpeciality(null);
  77.             }
  78.         }
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return Collection<int, Product>
  83.      */
  84.     public function getProducts(): Collection
  85.     {
  86.         return $this->products;
  87.     }
  88.     public function addProduct(Product $product): self
  89.     {
  90.         if (!$this->products->contains($product)) {
  91.             $this->products[] = $product;
  92.             $product->setSpecialite($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeProduct(Product $product): self
  97.     {
  98.         if ($this->products->removeElement($product)) {
  99.             // set the owning side to null (unless already changed)
  100.             if ($product->getSpecialite() === $this) {
  101.                 $product->setSpecialite(null);
  102.             }
  103.         }
  104.         return $this;
  105.     }
  106.     public function getNameEn(): ?string
  107.     {
  108.         return $this->name_en;
  109.     }
  110.     public function setNameEn(?string $name_en): self
  111.     {
  112.         $this->name_en $name_en;
  113.         return $this;
  114.     }
  115. }