src/Entity/Garages/GarageGroup.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Garages;
  3. use App\Annotation\SiteAware;
  4. use App\Doctrine\Generator\GarageGroupIdGenerator;
  5. use App\Entity\Interfaces\SiteInterface;
  6. use App\Entity\MiniAbstractBase;
  7. use App\Entity\Province;
  8. use App\Entity\Traits\CreatedAtTrait;
  9. use App\Entity\Traits\NameTrait;
  10. use App\Entity\Traits\SiteTrait;
  11. use App\Entity\Traits\UpdatedAtTrait;
  12. use App\Entity\UserGroup;
  13. use App\Repository\Garages\GarageGroupRepository;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\ORM\Mapping as ORM;
  17. /**
  18.  * @ORM\Table(name="vulco_garage_group", indexes={@ORM\Index(name="vulco_garage_group_site_idx", columns={"site"})})
  19.  *
  20.  * @ORM\Entity(repositoryClass=GarageGroupRepository::class)
  21.  *
  22.  * @SiteAware(siteFieldName="site")
  23.  */
  24. class GarageGroup implements SiteInterface
  25. {
  26.     use CreatedAtTrait;
  27.     use NameTrait;
  28.     use SiteTrait;
  29.     use UpdatedAtTrait;
  30.     /**
  31.      * @ORM\Id
  32.      *
  33.      * @ORM\Column(type="garage_group_id", length=255, nullable=false)
  34.      *
  35.      * @ORM\GeneratedValue(strategy="CUSTOM")
  36.      *
  37.      * @ORM\CustomIdGenerator(class=GarageGroupIdGenerator::class)
  38.      */
  39.     private string $id;
  40.     /**
  41.      * @ORM\Column(type="string", length=255)
  42.      */
  43.     private string $name;
  44.     /**
  45.      * @ORM\Column(type="boolean", nullable=true)
  46.      */
  47.     private ?bool $collective null;
  48.     /**
  49.      * @ORM\ManyToMany(targetEntity="App\Entity\Province", inversedBy="garageGroups")
  50.      *
  51.      * @ORM\JoinTable(name="vulco_garage_groups_provinces",
  52.      *     joinColumns={@ORM\JoinColumn(name="garage_group_id", referencedColumnName="id")},
  53.      *     inverseJoinColumns={@ORM\JoinColumn(name="province_id", referencedColumnName="id")}
  54.      * )
  55.      */
  56.     private ?Collection $provinces;
  57.     /**
  58.      * @ORM\ManyToMany(targetEntity="App\Entity\Garages\GarageVehicleType", inversedBy="garageGroups")
  59.      *
  60.      * @ORM\JoinTable(name="vulco_garage_groups_vehicle_types",
  61.      *     joinColumns={@ORM\JoinColumn(name="garage_group_id", referencedColumnName="id")},
  62.      *     inverseJoinColumns={@ORM\JoinColumn(name="vehicle_type_id", referencedColumnName="id")}
  63.      * )
  64.      */
  65.     private ?Collection $vehicleTypes;
  66.     /**
  67.      * @ORM\ManyToMany(targetEntity="App\Entity\UserGroup", inversedBy="garageGroups")
  68.      *
  69.      * @ORM\JoinTable(name="vulco_garage_groups_user_groups",
  70.      *     joinColumns={@ORM\JoinColumn(name="garage_group_id", referencedColumnName="id")},
  71.      *     inverseJoinColumns={@ORM\JoinColumn(name="user_group_id", referencedColumnName="id")}
  72.      * )
  73.      */
  74.     private ?Collection $userGroups;
  75.     public function __construct()
  76.     {
  77.         $this->provinces = new ArrayCollection();
  78.         $this->vehicleTypes = new ArrayCollection();
  79.         $this->userGroups = new ArrayCollection();
  80.     }
  81.     public function getId(): string
  82.     {
  83.         return $this->id;
  84.     }
  85.     public function getCollective(): ?bool
  86.     {
  87.         return $this->collective;
  88.     }
  89.     public function isCollective(): ?bool
  90.     {
  91.         return $this->getCollective();
  92.     }
  93.     public function setCollective(?bool $collective): self
  94.     {
  95.         $this->collective $collective;
  96.         return $this;
  97.     }
  98.     public function getProvinces(): ?Collection
  99.     {
  100.         return $this->provinces;
  101.     }
  102.     public function setProvinces(?Collection $provinces): self
  103.     {
  104.         $this->provinces $provinces;
  105.         return $this;
  106.     }
  107.     public function addProvince(Province $province): self
  108.     {
  109.         if (!$this->provinces->contains($province)) {
  110.             $this->provinces->add($province);
  111.             $province->addGarageGroup($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeProvince(Province $province): self
  116.     {
  117.         if ($this->provinces->contains($province)) {
  118.             $this->provinces->removeElement($province);
  119.         }
  120.         return $this;
  121.     }
  122.     public function getVehicleTypes(): ?Collection
  123.     {
  124.         return $this->vehicleTypes;
  125.     }
  126.     public function setVehicleTypes(?Collection $vehicleTypes): self
  127.     {
  128.         $this->vehicleTypes $vehicleTypes;
  129.         return $this;
  130.     }
  131.     public function addVehicleType(GarageVehicleType $vehicleType): self
  132.     {
  133.         if (!$this->vehicleTypes->contains($vehicleType)) {
  134.             $this->vehicleTypes->add($vehicleType);
  135.             $vehicleType->addGarageGroup($this);
  136.         }
  137.         return $this;
  138.     }
  139.     public function removeVehicleType(GarageVehicleType $vehicleType): self
  140.     {
  141.         if ($this->vehicleTypes->contains($vehicleType)) {
  142.             $this->vehicleTypes->removeElement($vehicleType);
  143.         }
  144.         return $this;
  145.     }
  146.     public function getUserGroups(): ?Collection
  147.     {
  148.         return $this->userGroups;
  149.     }
  150.     public function setUserGroups(?Collection $userGroups): self
  151.     {
  152.         $this->userGroups $userGroups;
  153.         return $this;
  154.     }
  155.     public function addUserGroup(UserGroup $userGroup): self
  156.     {
  157.         if (!$this->userGroups->contains($userGroup)) {
  158.             $this->userGroups->add($userGroup);
  159.             $userGroup->addGarageGroup($this);
  160.         }
  161.         return $this;
  162.     }
  163.     public function removeUserGroup(UserGroup $userGroup): self
  164.     {
  165.         if ($this->userGroups->contains($userGroup)) {
  166.             $this->userGroups->removeElement($userGroup);
  167.         }
  168.         return $this;
  169.     }
  170.     public function __toString(): string
  171.     {
  172.         return $this->id $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
  173.     }
  174. }