<?php

declare(strict_types=1);

namespace App\Entity;

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

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

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

    #[ORM\ManyToOne(targetEntity: Event::class)]
    #[ORM\JoinColumn(nullable: false)]
    private Event $event;

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

    #[ORM\Column(nullable: false)]
    private DateTimeImmutable $date;

    #[ORM\Column(type: "text", nullable: true)]
    protected ?string $note;

    #[ORM\Column]
    private DateTimeImmutable $createdAt;

    public function __construct(
        UserTrip $userTrip,
        Event $event,
        Location $location,
        DateTimeImmutable $date
    ) {
        $this->userTrip = $userTrip;
        $this->event = $event;
        $this->location = $location;
        $this->date = $date;
        $this->createdAt = new DateTimeImmutable();
    }

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

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

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

    public function getEvent(): Event
    {
        return $this->event;
    }

    public function setEvent(Event $event): void
    {
        $this->event = $event;
    }

    public function getLocation(): Location
    {
        return $this->location;
    }

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

    public function getDate(): DateTimeImmutable
    {
        return $this->date;
    }

    public function setDate(DateTimeImmutable $date): void
    {
        $this->date = $date;
    }

    public function getNote(): ?string
    {
        return $this->note;
    }

    public function setNote(?string $note): void
    {
        $this->note = $note;
    }

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