<?php

namespace App\Entity;

use App\Repository\UserFeedbackRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;

#[ORM\Entity(repositoryClass: UserFeedbackRepository::class)]
#[ORM\Index(columns: ['timestamp'], name: 'idx_feedback_timestamp')]
class UserFeedback
{
    #[ORM\Id]
    #[ORM\Column(type: UuidType::NAME, unique: true)]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
    private ?Uuid $id = null;

    #[ORM\Column(type: 'geometry', options: ['geometry_type' => 'POINT', 'srid' => 4326])]
    private mixed $location = null;

    #[ORM\ManyToOne(inversedBy: 'feedbacks')]
    #[ORM\JoinColumn(nullable: true)]
    private ?CoastalPoint $coastalPoint = null;

    #[ORM\Column]
    private \DateTimeImmutable $timestamp;

    #[ORM\Column]
    private bool $hasSeaweed;

    #[ORM\Column(length: 20, nullable: true)]
    private ?string $density = null;

    #[ORM\Column(length: 100, nullable: true)]
    private ?string $source = null;

    public function __construct()
    {
        $this->timestamp  = new \DateTimeImmutable();
        $this->hasSeaweed = false;
    }

    public function getId(): ?Uuid { return $this->id; }
    public function getLocation(): mixed { return $this->location; }
    public function setLocation(mixed $location): static { $this->location = $location; return $this; }
    public function getCoastalPoint(): ?CoastalPoint { return $this->coastalPoint; }
    public function setCoastalPoint(?CoastalPoint $coastalPoint): static { $this->coastalPoint = $coastalPoint; return $this; }
    public function getTimestamp(): \DateTimeImmutable { return $this->timestamp; }
    public function setTimestamp(\DateTimeImmutable $timestamp): static { $this->timestamp = $timestamp; return $this; }
    public function getHasSeaweed(): bool { return $this->hasSeaweed; }
    public function setHasSeaweed(bool $hasSeaweed): static { $this->hasSeaweed = $hasSeaweed; return $this; }
    public function getDensity(): ?string { return $this->density; }
    public function setDensity(?string $density): static { $this->density = $density; return $this; }
    public function getSource(): ?string { return $this->source; }
    public function setSource(?string $source): static { $this->source = $source; return $this; }
}
