src/Entity/Article/Service.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Article;
  3. use App\Entity\Article\Article;
  4. use App\Entity\Booking\Booking;
  5. use App\Repository\Article\ServiceRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Entity(repositoryClass=ServiceRepository::class)
  11.  */
  12. class Service extends Article
  13. {
  14.     /**
  15.      * @ORM\Column(type="float")
  16.      */
  17.     private $price;
  18.     /**
  19.      * @ORM\Column(type="integer", nullable=true)
  20.      */
  21.     private $duration;
  22.     /**
  23.      * @ORM\OneToMany(targetEntity=Booking::class, mappedBy="service")
  24.      */
  25.     private $bookings;
  26.     public function __construct()
  27.     {
  28.         parent::__construct();
  29.         $this->bookings = new ArrayCollection();
  30.     }
  31.     public function getPrice(): ?float
  32.     {
  33.         return $this->price;
  34.     }
  35.     public function setPrice(float $price): self
  36.     {
  37.         $this->price $price;
  38.         return $this;
  39.     }
  40.     public function getDuration(): ?int
  41.     {
  42.         return $this->duration;
  43.     }
  44.     public function setDuration(?int $duration): self
  45.     {
  46.         $this->duration $duration;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Booking>
  51.      */
  52.     public function getBookings(): Collection
  53.     {
  54.         return $this->bookings;
  55.     }
  56.     public function addBooking(Booking $booking): self
  57.     {
  58.         if (!$this->bookings->contains($booking)) {
  59.             $this->bookings[] = $booking;
  60.             $booking->setService($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeBooking(Booking $booking): self
  65.     {
  66.         if ($this->bookings->removeElement($booking)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($booking->getService() === $this) {
  69.                 $booking->setService(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74. }