src/Entity/BookAd.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BookAdRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClass: BookAdRepository::class)]
  9. class BookAd
  10. {
  11.     // rajouté le 04/04 à la correction de la veille pour state (bookCondition chez moi)
  12.     // curieux de voir que ça apparaît pas dans les setters, plus tard maybe ?
  13.     public const STATE_VERY_GOOD = "très bon état";
  14.     public const STATE_GOOD = "bon état";
  15.     public const STATE_USED = "usé";
  16.     public const STATE_VERY_USED = "très usé";
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     private ?int $id = null;
  21.     #[ORM\Column(length: 255)]
  22.     private ?string $title = null;
  23.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  24.     private ?string $description = null;
  25.     #[ORM\Column(type: Types::ARRAY, nullable: true)]
  26.     private array $imagesUrl = [];
  27.     #[ORM\Column(length: 255)]
  28.     private ?string $bookCondition = null;
  29.     #[ORM\Column(length: 255, nullable: true)]
  30.     private ?string $author = null;
  31.     #[ORM\Column(length: 255, nullable: true)]
  32.     private ?string $publishingHouse = null;
  33.     #[ORM\Column]
  34.     private ?float $price = null;
  35.     #[ORM\Column(type: Types::DATETIME_MUTABLE)]
  36.     private ?\DateTimeInterface $createdAt = null;
  37.     #[ORM\Column(type: Types::DATETIME_MUTABLE)]
  38.     private ?\DateTimeInterface $updatedAt = null;
  39.     #[ORM\ManyToOne(inversedBy: 'bookAds')]
  40.     #[ORM\JoinColumn(nullable: false)]
  41.     private ?User $user = null;
  42.     #[ORM\ManyToMany(targetEntity: Basket::class, mappedBy: 'books')]
  43.     private Collection $baskets;
  44.     public function __construct()
  45.     {
  46.         $this->baskets = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getTitle(): ?string
  53.     {
  54.         return $this->title;
  55.     }
  56.     public function setTitle(string $title): self
  57.     {
  58.         $this->title = $title;
  59.         return $this;
  60.     }
  61.     public function getDescription(): ?string
  62.     {
  63.         return $this->description;
  64.     }
  65.     public function setDescription(?string $description): self
  66.     {
  67.         $this->description = $description;
  68.         return $this;
  69.     }
  70.     public function getImagesUrl(): array
  71.     {
  72.         return $this->imagesUrl;
  73.     }
  74.     public function setImagesUrl(?array $imagesUrl): self
  75.     {
  76.         $this->imagesUrl = $imagesUrl;
  77.         return $this;
  78.     }
  79.     public function getBookCondition(): ?string
  80.     {
  81.         return $this->bookCondition;
  82.     }
  83.     public function setBookCondition(string $bookCondition): self
  84.     {
  85.         $this->bookCondition = $bookCondition;
  86.         return $this;
  87.     }
  88.     public function getAuthor(): ?string
  89.     {
  90.         return $this->author;
  91.     }
  92.     public function setAuthor(?string $author): self
  93.     {
  94.         $this->author = $author;
  95.         return $this;
  96.     }
  97.     public function getPublishingHouse(): ?string
  98.     {
  99.         return $this->publishingHouse;
  100.     }
  101.     public function setPublishingHouse(?string $publishingHouse): self
  102.     {
  103.         $this->publishingHouse = $publishingHouse;
  104.         return $this;
  105.     }
  106.     public function getPrice(): ?float
  107.     {
  108.         return $this->price;
  109.     }
  110.     public function setPrice(float $price): self
  111.     {
  112.         $this->price = $price;
  113.         return $this;
  114.     }
  115.     public function getCreatedAt(): ?\DateTimeInterface
  116.     {
  117.         return $this->createdAt;
  118.     }
  119.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  120.     {
  121.         $this->createdAt = $createdAt;
  122.         return $this;
  123.     }
  124.     public function getUpdatedAt(): ?\DateTimeInterface
  125.     {
  126.         return $this->updatedAt;
  127.     }
  128.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  129.     {
  130.         $this->updatedAt = $updatedAt;
  131.         return $this;
  132.     }
  133.     public function getUser(): ?User
  134.     {
  135.         return $this->user;
  136.     }
  137.     public function setUser(?User $user): self
  138.     {
  139.         $this->user = $user;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return Collection<int, Basket>
  144.      */
  145.     public function getBaskets(): Collection
  146.     {
  147.         return $this->baskets;
  148.     }
  149.     public function addBasket(Basket $basket): self
  150.     {
  151.         if (!$this->baskets->contains($basket)) {
  152.             $this->baskets->add($basket);
  153.             $basket->addBook($this);
  154.         }
  155.         return $this;
  156.     }
  157.     public function removeBasket(Basket $basket): self
  158.     {
  159.         if ($this->baskets->removeElement($basket)) {
  160.             $basket->removeBook($this);
  161.         }
  162.         return $this;
  163.     }
  164. }