src/Entity/Province.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Annotation\SiteAware;
  4. use App\Entity\Garages\GarageGroup;
  5. use App\Entity\Interfaces\SiteInterface;
  6. use App\Entity\Traits\NameTrait;
  7. use App\Entity\Traits\SiteTrait;
  8. use App\Repository\ProvinceRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. /**
  14.  * @ORM\Table(name="vulco_province", indexes={@ORM\Index(name="slider_province_site_idx", columns={"site"})})
  15.  * @ORM\Entity(repositoryClass=ProvinceRepository::class)
  16.  * @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
  17.  * @SiteAware(siteFieldName="site")
  18.  */
  19. class Province extends AbstractBase implements SiteInterface
  20. {
  21.     use SiteTrait;
  22.     use NameTrait;
  23.     /**
  24.      * @ORM\Column(type="string", length=255, nullable=false)
  25.      */
  26.     private string $name;
  27.     /**
  28.      * @ORM\ManyToMany(targetEntity="App\Entity\Garages\GarageGroup", mappedBy="provinces")
  29.      */
  30.     private ?Collection $garageGroups;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity="App\Entity\Region", fetch="EAGER")
  33.      */
  34.     private ?Region $region null;
  35.     public function __construct()
  36.     {
  37.         $this->garageGroups = new ArrayCollection();
  38.     }
  39.     public function __clone() {
  40.         if ($this->id) {
  41.             if (!is_null($this->garageGroups)) {
  42.                 $this->garageGroups = clone $this->garageGroups;
  43.             }
  44.         }
  45.     }
  46.     public function getGarageGroups(): ?Collection
  47.     {
  48.         return $this->garageGroups;
  49.     }
  50.     public function setGarageGroups(?Collection $garageGroups): self
  51.     {
  52.         $this->garageGroups $garageGroups;
  53.         return $this;
  54.     }
  55.     public function addGarageGroup(GarageGroup $garageGroup): self
  56.     {
  57.         if (!$this->garageGroups->contains($garageGroup)) {
  58.             $this->garageGroups->add($garageGroup);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeGarageGroup(GarageGroup $garageGroup): self
  63.     {
  64.         if ($this->garageGroups->contains($garageGroup)) {
  65.             $this->garageGroups->removeElement($garageGroup);
  66.         }
  67.         return $this;
  68.     }
  69.     public function getRegion(): ?Region
  70.     {
  71.         return $this->region;
  72.     }
  73.     public function setRegion(?Region $region): self
  74.     {
  75.         $this->region $region;
  76.         return $this;
  77.     }
  78.     public function diff(Province $province): bool
  79.     {
  80.         if (
  81.             ($this->name !== $province->name)
  82.         )
  83.         {
  84.             return true;
  85.         }
  86.         return false;
  87.     }
  88.     public function __toString(): string
  89.     {
  90.         return $this->id $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
  91.     }
  92. }