<?phpnamespace App\Entity;use App\Repository\BookAdRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: BookAdRepository::class)]class BookAd{ // rajouté le 04/04 à la correction de la veille pour state (bookCondition chez moi) // curieux de voir que ça apparaît pas dans les setters, plus tard maybe ? public const STATE_VERY_GOOD = "très bon état"; public const STATE_GOOD = "bon état"; public const STATE_USED = "usé"; public const STATE_VERY_USED = "très usé"; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $title = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $description = null; #[ORM\Column(type: Types::ARRAY, nullable: true)] private array $imagesUrl = []; #[ORM\Column(length: 255)] private ?string $bookCondition = null; #[ORM\Column(length: 255, nullable: true)] private ?string $author = null; #[ORM\Column(length: 255, nullable: true)] private ?string $publishingHouse = null; #[ORM\Column] private ?float $price = null; #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $createdAt = null; #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $updatedAt = null; #[ORM\ManyToOne(inversedBy: 'bookAds')] #[ORM\JoinColumn(nullable: false)] private ?User $user = null; #[ORM\ManyToMany(targetEntity: Basket::class, mappedBy: 'books')] private Collection $baskets; public function __construct() { $this->baskets = new ArrayCollection(); } 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; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getImagesUrl(): array { return $this->imagesUrl; } public function setImagesUrl(?array $imagesUrl): self { $this->imagesUrl = $imagesUrl; return $this; } public function getBookCondition(): ?string { return $this->bookCondition; } public function setBookCondition(string $bookCondition): self { $this->bookCondition = $bookCondition; return $this; } public function getAuthor(): ?string { return $this->author; } public function setAuthor(?string $author): self { $this->author = $author; return $this; } public function getPublishingHouse(): ?string { return $this->publishingHouse; } public function setPublishingHouse(?string $publishingHouse): self { $this->publishingHouse = $publishingHouse; return $this; } public function getPrice(): ?float { return $this->price; } public function setPrice(float $price): self { $this->price = $price; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } /** * @return Collection<int, Basket> */ public function getBaskets(): Collection { return $this->baskets; } public function addBasket(Basket $basket): self { if (!$this->baskets->contains($basket)) { $this->baskets->add($basket); $basket->addBook($this); } return $this; } public function removeBasket(Basket $basket): self { if ($this->baskets->removeElement($basket)) { $basket->removeBook($this); } return $this; }}