<?php
namespace App\Entity\Garages;
use App\Annotation\SiteAware;
use App\Doctrine\Generator\GarageOwnerIdGenerator;
use App\Entity\Interfaces\ImageInterface;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\MiniAbstractBase;
use App\Entity\Traits\CreatedAtTrait;
use App\Entity\Traits\GarageTrait;
use App\Entity\Traits\HasImageTrait;
use App\Entity\Traits\NameTrait;
use App\Entity\Traits\PhoneTrait;
use App\Entity\Traits\SiteTrait;
use App\Entity\Traits\UpdatedAtTrait;
use App\Repository\Garages\GarageOwnerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Table(name="vulco_garage_owner", indexes={@ORM\Index(name="garage_owner_site_idx", columns={"site"})})
*
* @ORM\Entity(repositoryClass=GarageOwnerRepository::class)
*
* @SiteAware(siteFieldName="site")
*
* @Vich\Uploadable
*/
class GarageOwner implements SiteInterface, ImageInterface
{
use CreatedAtTrait;
use GarageTrait;
use HasImageTrait;
use NameTrait;
use PhoneTrait;
use SiteTrait;
use UpdatedAtTrait;
/**
* @ORM\Id
*
* @ORM\Column(type="garage_owner_id", length=255, nullable=false)
*
* @ORM\GeneratedValue(strategy="CUSTOM")
*
* @ORM\CustomIdGenerator(class=GarageOwnerIdGenerator::class)
*/
private string $id;
/**
* @Vich\UploadableField(mapping="garage_owner_image", fileNameProperty="imageName")
*/
private ?File $image = null;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $name;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $surnames;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $mail;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $phoneService = null;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": 0})
*/
private ?bool $isRepresentative = false;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Garages\Garage", inversedBy="garageOwner")
*
* @ORM\JoinColumn(name="garage_id", referencedColumnName="id")
*/
private Garage $garage;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Province")
*
* @ORM\JoinTable(name="vulco_garage_owner_provinces_assigned_as_a_representative",
* joinColumns={@ORM\JoinColumn(name="garage_owner_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="province_id", referencedColumnName="id")}
* )
*/
private ?Collection $provincesAssignedAsARepresentative;
public function __construct()
{
$this->provincesAssignedAsARepresentative = new ArrayCollection();
}
public function getId(): string
{
return $this->id;
}
public function setFakeId(string $fakeId): self
{
$this->id = $fakeId;
return $this;
}
public function getFullname(): string
{
return $this->getName().' '.$this->getSurnames();
}
public function getSurnames(): string
{
return $this->surnames;
}
public function setSurnames(string $surnames): self
{
$this->surnames = $surnames;
return $this;
}
public function getMail(): string
{
return $this->mail;
}
public function setMail(string $mail): self
{
$this->mail = $mail;
return $this;
}
public function getPhoneService(): ?string
{
return $this->phoneService;
}
public function setPhoneService(?string $phoneService): self
{
$this->phoneService = $phoneService;
return $this;
}
public function isRepresentative(): ?bool
{
return $this->isRepresentative;
}
public function getIsRepresentative(): ?bool
{
return $this->isRepresentative();
}
public function setIsRepresentative(?bool $isRepresentative): self
{
$this->isRepresentative = $isRepresentative;
return $this;
}
public function getProvincesAssignedAsARepresentative(): ?Collection
{
return $this->provincesAssignedAsARepresentative;
}
public function setProvincesAssignedAsARepresentative(?Collection $provincesAssignedAsARepresentative): self
{
$this->provincesAssignedAsARepresentative = $provincesAssignedAsARepresentative;
return $this;
}
public function __toString(): string
{
return $this->id ? $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
}
}