<?php
namespace App\Entity;
use App\Repository\BranchesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=BranchesRepository::class)
*/
class Branches
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address;
/**
* @ORM\OneToMany(targetEntity=Car::class, mappedBy="branches")
*/
private $carId;
public function __construct()
{
$this->carId = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
/**
* @return Collection<int, Car>
*/
public function getCarId(): Collection
{
return $this->carId;
}
public function addCarId(Car $carId): self
{
if (!$this->carId->contains($carId)) {
$this->carId[] = $carId;
$carId->setBranches($this);
}
return $this;
}
public function removeCarId(Car $carId): self
{
if ($this->carId->removeElement($carId)) {
// set the owning side to null (unless already changed)
if ($carId->getBranches() === $this) {
$carId->setBranches(null);
}
}
return $this;
}
public function __toString()
{
return $this->name;
}
}