<?php

declare(strict_types=1);

namespace App\Entity;

use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'location')]
class Location
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\ManyToOne(targetEntity: Zone::class, inversedBy: 'locations')]
    #[ORM\JoinColumn(nullable: false)]
    private Zone $zone;

    #[ORM\Column(length: 255)]
    private string $code;

    #[ORM\Column(length: 255)]
    private string $name;

    #[ORM\Column]
    private DateTimeImmutable $createdAt;

    #[ORM\OneToMany(targetEntity: TripLocation::class, mappedBy: 'location')]
    private Collection $tripLocations;

    #[ORM\OneToMany(targetEntity: UserTripLocation::class, mappedBy: 'location')]
    private Collection $userTripLocations;

    #[ORM\OneToMany(targetEntity: UserTripWorkLog::class, mappedBy: 'startLocation')]
    private Collection $startWorkLogs;

    #[ORM\OneToMany(targetEntity: UserTripWorkLog::class, mappedBy: 'endLocation')]
    private Collection $endWorkLogs;

    public function __construct(Zone $zone, string $name, string $code)
    {
        $this->zone = $zone;
        $this->name = $name;
        $this->code = $code;
        $this->createdAt = new DateTimeImmutable();
        $this->tripLocations = new ArrayCollection();
        $this->userTripLocations = new ArrayCollection();
        $this->startWorkLogs = new ArrayCollection();
        $this->endWorkLogs = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getZone(): Zone
    {
        return $this->zone;
    }

    public function setZone(Zone $zone): self
    {
        $this->zone = $zone;
        return $this;
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;
        return $this;
    }

    public function getCode(): string
    {
        return $this->code;
    }

    public function setCode(string $code): void
    {
        $this->code = $code;
    }

    public function getCreatedAt(): DateTimeImmutable
    {
        return $this->createdAt;
    }

    public function getTripLocations(): Collection
    {
        return $this->tripLocations;
    }

    public function getUserTripLocations(): Collection
    {
        return $this->userTripLocations;
    }

    public function getStartWorkLogs(): Collection
    {
        return $this->startWorkLogs;
    }

    public function getEndWorkLogs(): Collection
    {
        return $this->endWorkLogs;
    }

}