download
raw
2.71 kB
<?php
namespace App\Entity;
use App\Repository\AuthorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
//les deux contraintes de validation
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[UniqueEntity(['name'])]
#[ORM\Entity(repositoryClass: AuthorRepository::class)]
class Author
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Assert\Length(min:10)]
#[Assert\NotBlank()]
#[ORM\Column(length: 255)]
private ?string $name = null;
#[Assert\NotBlank()]
#[ORM\Column]
private ?\DateTimeImmutable $dateOfBirth = null;
#[Assert\GreaterThan(propertyPath: 'dateOfBirth')]
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $dateOfDeath = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $nationality = null;
/**
* @var Collection<int, Book>
*/
#[ORM\ManyToMany(targetEntity: Book::class, inversedBy: 'authors')]
private Collection $books;
public function __construct()
{
$this->books = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getDateOfBirth(): ?\DateTimeImmutable
{
return $this->dateOfBirth;
}
public function setDateOfBirth(\DateTimeImmutable $dateOfBirth): static
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
public function getDateOfDeath(): ?\DateTimeImmutable
{
return $this->dateOfDeath;
}
public function setDateOfDeath(?\DateTimeImmutable $dateOfDeath): static
{
$this->dateOfDeath = $dateOfDeath;
return $this;
}
public function getNationality(): ?string
{
return $this->nationality;
}
public function setNationality(?string $nationality): static
{
$this->nationality = $nationality;
return $this;
}
/**
* @return Collection<int, Book>
*/
public function getBooks(): Collection
{
return $this->books;
}
public function addBook(Book $book): static
{
if (!$this->books->contains($book)) {
$this->books->add($book);
}
return $this;
}
public function removeBook(Book $book): static
{
$this->books->removeElement($book);
return $this;
}
}

Xet Storage Details

Size:
2.71 kB
·
Xet hash:
32d8ae2c489de9943b5f7f310bab804bb1545d9138cd71450661b704cf4413c0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.