<?php

declare(strict_types=1);

namespace App\Entity;

use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;

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

    #[ORM\ManyToOne(targetEntity: UserTrip::class, inversedBy: 'workLogs')]
    #[ORM\JoinColumn(nullable: false)]
    private UserTrip $userTrip;

    #[ORM\ManyToOne(targetEntity: Location::class, inversedBy: 'startWorkLogs')]
    #[ORM\JoinColumn(name: 'start_location_id', nullable: false)]
    private Location $startLocation;

    #[ORM\ManyToOne(targetEntity: Location::class, inversedBy: 'endWorkLogs')]
    #[ORM\JoinColumn(name: 'end_location_id', nullable: false)]
    private Location $endLocation;

    #[ORM\Column]
    private DateTimeImmutable $startDate;

    #[ORM\Column]
    private DateTimeImmutable $endDate;

    #[ORM\Column]
    private DateTimeImmutable $createdAt;

    public function __construct(
        UserTrip $userTrip,
        Location $startLocation,
        Location $endLocation,
        DateTimeImmutable $startDate,
        DateTimeImmutable $endDate
    ) {
        $this->userTrip = $userTrip;
        $this->startLocation = $startLocation;
        $this->endLocation = $endLocation;
        $this->startDate = $startDate;
        $this->endDate = $endDate;
        $this->createdAt = new DateTimeImmutable();
    }

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

    public function getUserTrip(): UserTrip
    {
        return $this->userTrip;
    }

    public function setUserTrip(UserTrip $userTrip): self
    {
        $this->userTrip = $userTrip;
        return $this;
    }

    public function getStartLocation(): Location
    {
        return $this->startLocation;
    }

    public function setStartLocation(Location $startLocation): self
    {
        $this->startLocation = $startLocation;
        return $this;
    }

    public function getEndLocation(): Location
    {
        return $this->endLocation;
    }

    public function setEndLocation(Location $endLocation): self
    {
        $this->endLocation = $endLocation;
        return $this;
    }

    public function getStartDate(): DateTimeImmutable
    {
        return $this->startDate;
    }

    public function setStartDate(DateTimeImmutable $startDate): self
    {
        $this->startDate = $startDate;
        return $this;
    }

    public function getEndDate(): DateTimeImmutable
    {
        return $this->endDate;
    }

    public function setEndDate(DateTimeImmutable $endDate): self
    {
        $this->endDate = $endDate;
        return $this;
    }

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