253 lines
5.2 KiB
PHP
253 lines
5.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\MangaRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: MangaRepository::class)]
|
|
class Manga
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $title = null;
|
|
|
|
#[ORM\OneToMany(mappedBy: 'manga', targetEntity: Chapter::class, fetch: 'EAGER', orphanRemoval: true)]
|
|
private Collection $chapters;
|
|
|
|
#[ORM\Column(length: 255, unique: true)]
|
|
private ?string $slug = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $imageUrl = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?int $publicationYear = null;
|
|
|
|
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
|
private ?string $description = null;
|
|
|
|
#[ORM\Column(type: Types::ARRAY, nullable: true)]
|
|
private ?array $genres = null;
|
|
|
|
#[ORM\Column]
|
|
private ?\DateTimeImmutable $createdAt = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?float $rating = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $author = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $externalId = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $status = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $thumbnailUrl = null;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->chapters = new ArrayCollection();
|
|
$this->createdAt = new \DateTimeImmutable();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getTitle(): ?string
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
public function setTitle(string $title): self
|
|
{
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Chapter>
|
|
*/
|
|
public function getChapters(): Collection
|
|
{
|
|
return $this->chapters;
|
|
}
|
|
|
|
public function getChapterByNumber(float $number): ?Chapter
|
|
{
|
|
foreach ($this->chapters as $chapter) {
|
|
if ($chapter->getNumber() === $number) {
|
|
return $chapter;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function addChapter(Chapter $chapter): self
|
|
{
|
|
if (!$this->chapters->contains($chapter)) {
|
|
$this->chapters->add($chapter);
|
|
$chapter->setManga($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeChapter(Chapter $chapter): self
|
|
{
|
|
if ($this->chapters->removeElement($chapter)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($chapter->getManga() === $this) {
|
|
$chapter->setManga(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSlug(): ?string
|
|
{
|
|
return $this->slug;
|
|
}
|
|
|
|
public function setSlug(string $slug): self
|
|
{
|
|
$this->slug = $slug;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getImageUrl(): ?string
|
|
{
|
|
return $this->imageUrl;
|
|
}
|
|
|
|
public function setImageUrl(?string $imageUrl): static
|
|
{
|
|
$this->imageUrl = $imageUrl;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPublicationYear(): ?int
|
|
{
|
|
return $this->publicationYear;
|
|
}
|
|
|
|
public function setPublicationYear(?int $publicationYear): static
|
|
{
|
|
$this->publicationYear = $publicationYear;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDescription(): ?string
|
|
{
|
|
return $this->description;
|
|
}
|
|
|
|
public function setDescription(?string $description): static
|
|
{
|
|
$this->description = $description;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getGenres(): ?array
|
|
{
|
|
return $this->genres;
|
|
}
|
|
|
|
public function setGenres(?array $genres): static
|
|
{
|
|
$this->genres = $genres;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->createdAt;
|
|
}
|
|
|
|
public function setCreatedAt(\DateTimeImmutable $createdAt): static
|
|
{
|
|
$this->createdAt = $createdAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getRating(): ?float
|
|
{
|
|
return $this->rating;
|
|
}
|
|
|
|
public function setRating(?float $rating): static
|
|
{
|
|
$this->rating = $rating;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAuthor(): ?string
|
|
{
|
|
return $this->author;
|
|
}
|
|
|
|
public function setAuthor(?string $author): static
|
|
{
|
|
$this->author = $author;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getExternalId(): ?string
|
|
{
|
|
return $this->externalId;
|
|
}
|
|
|
|
public function setExternalId(?string $externalId): static
|
|
{
|
|
$this->externalId = $externalId;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStatus(): ?string
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function setStatus(?string $status): static
|
|
{
|
|
$this->status = $status;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getThumbnailUrl(): ?string
|
|
{
|
|
return $this->thumbnailUrl;
|
|
}
|
|
|
|
public function setThumbnailUrl(?string $thumbnailUrl): static
|
|
{
|
|
$this->thumbnailUrl = $thumbnailUrl;
|
|
|
|
return $this;
|
|
}
|
|
}
|