<?php
namespace App\Entity;
use App\Repository\DestinationsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=DestinationsRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class Destinations
{
/**
* @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 $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255)
*/
private $type;
/**
* @ORM\OneToMany(targetEntity=Transfers::class, mappedBy="destination")
*/
private $transfers;
/**
* @ORM\OneToMany(targetEntity=Car::class, mappedBy="destination")
*/
private $cars;
public function __construct()
{
$this->transfers = new ArrayCollection();
$this->cars = 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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAt(): self
{
$this->createdAt = new \DateTime();
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAt(): self
{
$this->updatedAt = new \DateTime();
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, Transfers>
*/
public function getTransfers(): Collection
{
return $this->transfers;
}
public function addTransfer(Transfers $transfer): self
{
if (!$this->transfers->contains($transfer)) {
$this->transfers[] = $transfer;
$transfer->setDestination($this);
}
return $this;
}
public function removeTransfer(Transfers $transfer): self
{
if ($this->transfers->removeElement($transfer)) {
// set the owning side to null (unless already changed)
if ($transfer->getDestination() === $this) {
$transfer->setDestination(null);
}
}
return $this;
}
public function __toString()
{
return $this->name;
}
/**
* @return Collection<int, Car>
*/
public function getCars(): Collection
{
return $this->cars;
}
public function addCar(Car $car): self
{
if (!$this->cars->contains($car)) {
$this->cars[] = $car;
$car->setDestination($this);
}
return $this;
}
public function removeCar(Car $car): self
{
if ($this->cars->removeElement($car)) {
// set the owning side to null (unless already changed)
if ($car->getDestination() === $this) {
$car->setDestination(null);
}
}
return $this;
}
}