Files
genshin-world/src/Entity/Map.php
2025-07-15 01:15:37 +02:00

90 lines
2.0 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\MapRepository;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\UploadedFile;
#[ORM\Entity(repositoryClass: MapRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[UniqueEntity(fields: ['file'], message: 'There is already a file with this name')]
class Map {
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer', options: ['unsigned' => true])]
private $id;
#[ORM\ManyToOne(targetEntity: Grid::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private $grid;
#[ORM\Column(type: 'string', length: 50, unique: true)]
private $file;
#[ORM\Column(type: 'datetime')]
private $modifiedAt;
#[ORM\Column(type: 'float')]
private $version;
public function __toString(): string {
return $this->getFile();
}
#[ORM\PrePersist]
#[ORM\PreUpdate]
public function updateLifecycle() {
$this->setModifiedAt(new DateTime());
}
public function getId(): ?int {
return $this->id;
}
public function getGrid(): ?Grid
{
return $this->grid;
}
public function setGrid(?Grid $grid): self
{
$this->grid = $grid;
return $this;
}
public function getFile(): string|UploadedFile|null {
return $this->file;
}
public function setFile(string|UploadedFile|null $file): self {
$this->file=$file;
return $this;
}
public function getModifiedAt(): ?DateTimeInterface {
return $this->modifiedAt;
}
public function setModifiedAt(DateTimeInterface $modifiedAt): self {
$this->modifiedAt=$modifiedAt;
return $this;
}
public function getVersion(): ?float {
return $this->version;
}
public function setVersion(float $version): self {
$this->version=$version;
return $this;
}
}