<?php
namespace App\Entity;
use App\Repository\DepartmentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=DepartmentRepository::class)
*/
class Department
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @Gedmo\Slug(fields={"name"}, unique=true)
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\Column(type="boolean")
*/
private $status = false;
/**
* @ORM\OneToMany(targetEntity=Transporteur::class, mappedBy="department")
*/
private $transporteurs;
/**
* @ORM\ManyToOne(targetEntity=Country::class, inversedBy="departments")
* @ORM\JoinColumn(nullable=true)
*/
private $country;
public function __construct()
{
$this->transporteurs = 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 getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function isStatus(): ?bool
{
return $this->status;
}
public function setStatus(bool $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, Transporteur>
*/
public function getTransporteurs(): Collection
{
return $this->transporteurs;
}
public function addTransporteur(Transporteur $transporteur): self
{
if (!$this->transporteurs->contains($transporteur)) {
$this->transporteurs[] = $transporteur;
$transporteur->setDepartment($this);
}
return $this;
}
public function removeTransporteur(Transporteur $transporteur): self
{
if ($this->transporteurs->removeElement($transporteur)) {
// set the owning side to null (unless already changed)
if ($transporteur->getDepartment() === $this) {
$transporteur->setDepartment(null);
}
}
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
}