<?php
namespace App\Entity\Garages;
use App\Annotation\SiteAware;
use App\Doctrine\Generator\GarageGroupIdGenerator;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\MiniAbstractBase;
use App\Entity\Province;
use App\Entity\Traits\CreatedAtTrait;
use App\Entity\Traits\NameTrait;
use App\Entity\Traits\SiteTrait;
use App\Entity\Traits\UpdatedAtTrait;
use App\Entity\UserGroup;
use App\Repository\Garages\GarageGroupRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="vulco_garage_group", indexes={@ORM\Index(name="vulco_garage_group_site_idx", columns={"site"})})
*
* @ORM\Entity(repositoryClass=GarageGroupRepository::class)
*
* @SiteAware(siteFieldName="site")
*/
class GarageGroup implements SiteInterface
{
use CreatedAtTrait;
use NameTrait;
use SiteTrait;
use UpdatedAtTrait;
/**
* @ORM\Id
*
* @ORM\Column(type="garage_group_id", length=255, nullable=false)
*
* @ORM\GeneratedValue(strategy="CUSTOM")
*
* @ORM\CustomIdGenerator(class=GarageGroupIdGenerator::class)
*/
private string $id;
/**
* @ORM\Column(type="string", length=255)
*/
private string $name;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $collective = null;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Province", inversedBy="garageGroups")
*
* @ORM\JoinTable(name="vulco_garage_groups_provinces",
* joinColumns={@ORM\JoinColumn(name="garage_group_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="province_id", referencedColumnName="id")}
* )
*/
private ?Collection $provinces;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Garages\GarageVehicleType", inversedBy="garageGroups")
*
* @ORM\JoinTable(name="vulco_garage_groups_vehicle_types",
* joinColumns={@ORM\JoinColumn(name="garage_group_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="vehicle_type_id", referencedColumnName="id")}
* )
*/
private ?Collection $vehicleTypes;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\UserGroup", inversedBy="garageGroups")
*
* @ORM\JoinTable(name="vulco_garage_groups_user_groups",
* joinColumns={@ORM\JoinColumn(name="garage_group_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="user_group_id", referencedColumnName="id")}
* )
*/
private ?Collection $userGroups;
public function __construct()
{
$this->provinces = new ArrayCollection();
$this->vehicleTypes = new ArrayCollection();
$this->userGroups = new ArrayCollection();
}
public function getId(): string
{
return $this->id;
}
public function getCollective(): ?bool
{
return $this->collective;
}
public function isCollective(): ?bool
{
return $this->getCollective();
}
public function setCollective(?bool $collective): self
{
$this->collective = $collective;
return $this;
}
public function getProvinces(): ?Collection
{
return $this->provinces;
}
public function setProvinces(?Collection $provinces): self
{
$this->provinces = $provinces;
return $this;
}
public function addProvince(Province $province): self
{
if (!$this->provinces->contains($province)) {
$this->provinces->add($province);
$province->addGarageGroup($this);
}
return $this;
}
public function removeProvince(Province $province): self
{
if ($this->provinces->contains($province)) {
$this->provinces->removeElement($province);
}
return $this;
}
public function getVehicleTypes(): ?Collection
{
return $this->vehicleTypes;
}
public function setVehicleTypes(?Collection $vehicleTypes): self
{
$this->vehicleTypes = $vehicleTypes;
return $this;
}
public function addVehicleType(GarageVehicleType $vehicleType): self
{
if (!$this->vehicleTypes->contains($vehicleType)) {
$this->vehicleTypes->add($vehicleType);
$vehicleType->addGarageGroup($this);
}
return $this;
}
public function removeVehicleType(GarageVehicleType $vehicleType): self
{
if ($this->vehicleTypes->contains($vehicleType)) {
$this->vehicleTypes->removeElement($vehicleType);
}
return $this;
}
public function getUserGroups(): ?Collection
{
return $this->userGroups;
}
public function setUserGroups(?Collection $userGroups): self
{
$this->userGroups = $userGroups;
return $this;
}
public function addUserGroup(UserGroup $userGroup): self
{
if (!$this->userGroups->contains($userGroup)) {
$this->userGroups->add($userGroup);
$userGroup->addGarageGroup($this);
}
return $this;
}
public function removeUserGroup(UserGroup $userGroup): self
{
if ($this->userGroups->contains($userGroup)) {
$this->userGroups->removeElement($userGroup);
}
return $this;
}
public function __toString(): string
{
return $this->id ? $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
}
}