<?php
namespace App\Entity\Garages;
use App\Annotation\SiteAware;
use App\Entity\AbstractBase;
use App\Entity\Interfaces\ImageInterface;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\MiniAbstractBase;
use App\Entity\Traits\HasImageTrait;
use App\Entity\Traits\NameTrait;
use App\Entity\Traits\SiteTrait;
use App\Repository\Garages\GarageVehicleTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Table(name="vulco_garage_vehicle_type", indexes={@ORM\Index(name="garage_vehicle_type_site_idx", columns={"site"})}, uniqueConstraints={@ORM\UniqueConstraint(name="garage_vehicle_search_idx", columns={"site", "name"})})
*
* @ORM\Entity(repositoryClass=GarageVehicleTypeRepository::class)
*
* @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
*
* @SiteAware(siteFieldName="site")
*
* @Vich\Uploadable
*/
class GarageVehicleType extends AbstractBase implements ImageInterface, SiteInterface
{
use HasImageTrait;
use NameTrait;
use SiteTrait;
/**
* @Vich\UploadableField(mapping="garage_vehicle_type_image", fileNameProperty="imageName")
*/
private ?File $image = null;
/**
* @ORM\Column(type="string", length=255)
*/
private string $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $nameCa = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $imageName = null;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Garages\GarageGroup", mappedBy="vehicleTypes")
*/
private ?Collection $garageGroups;
public function __construct()
{
$this->garageGroups = new ArrayCollection();
}
public function getNameCa(): ?string
{
return $this->nameCa;
}
public function setNameCa(?string $nameCa): self
{
$this->nameCa = $nameCa;
return $this;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageName(?string $imageName): self
{
$this->imageName = $imageName;
return $this;
}
public function garageGroups(): ?Collection
{
return $this->garageGroups;
}
public function setGarageGroups(?Collection $garageGroups): self
{
$this->garageGroups = $garageGroups;
return $this;
}
public function addGarageGroup(GarageGroup $garageGroup): self
{
if (!$this->garageGroups->contains($garageGroup)) {
$this->garageGroups->add($garageGroup);
}
return $this;
}
public function removeGarageGroup(GarageGroup $garageGroup): self
{
if ($this->garageGroups->contains($garageGroup)) {
$this->garageGroups->removeElement($garageGroup);
}
return $this;
}
public function __toString(): string
{
return $this->getId() ? $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
}
}