<?php

declare(strict_types=1);

namespace App\Entity;

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

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

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

    #[ORM\ManyToOne(targetEntity: Location::class, inversedBy: 'userTripLocations')]
    #[ORM\JoinColumn(nullable: false)]
    private Location $location;

    #[ORM\Column]
    private DateTimeImmutable $plannedDate;

    #[ORM\Column]
    private DateTimeImmutable $createdAt;

    public function __construct(UserTrip $userTrip, Location $location, DateTimeImmutable $plannedDate)
    {
        $this->userTrip = $userTrip;
        $this->location = $location;
        $this->plannedDate = $plannedDate;
        $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 getLocation(): Location
    {
        return $this->location;
    }

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

    public function getPlannedDate(): DateTimeImmutable
    {
        return $this->plannedDate;
    }

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

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