src/Entity/Federation/Boat.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Federation;
  3. use App\Entity\Media\Document;
  4. use App\Entity\Site\AccessSite;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\Federation\BoatRepository")
  12.  * @ORM\Table(name="boats")
  13.  */
  14. class Boat
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\Column(type="integer")
  19.      * @ORM\GeneratedValue(strategy="AUTO")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255, nullable=false)
  24.      * @Assert\NotBlank()
  25.      */
  26.     private $name;
  27.     
  28.     /**
  29.      * @ORM\Column(type="string", length=255, nullable=true)
  30.      */
  31.     private $number;
  32.     /**
  33.      * @ORM\Column(type="datetime", nullable=false, name="created_date")
  34.      * @Gedmo\Timestampable(on="create")
  35.      */
  36.     private $createdDate;
  37.     /**
  38.      * @ORM\Column(type="datetime", nullable=true, name="updated_date")
  39.      * @Gedmo\Timestampable(on="update")
  40.      */
  41.     private $updatedDate;
  42.     /**
  43.      * @ORM\Column(type="integer", nullable=true, name="status")
  44.      */
  45.     private $status 1
  46.     /**
  47.      * @ORM\OneToMany(targetEntity="App\Entity\Federation\Participation", mappedBy="boat", cascade={"remove"})
  48.      */
  49.     private $participations;
  50.      /**
  51.      * @ORM\ManyToOne(targetEntity="App\Entity\Federation\Classe", inversedBy="boats", cascade={"persist"})
  52.      * @ORM\JoinColumn(name="classe_id", referencedColumnName="id", nullable=false)
  53.      * @Assert\NotBlank()
  54.      */
  55.     private $classe;
  56.     /**
  57.      * @ORM\ManyToMany(targetEntity="App\Entity\Site\AccessSite", mappedBy="boats")
  58.      */
  59.     private $accessSites;
  60.     /**
  61.      * @ORM\ManyToMany(targetEntity="App\Entity\Media\Document", mappedBy="boats")
  62.      */
  63.     private $documents;
  64.     public function __construct()
  65.     {
  66.         $this->participations = new ArrayCollection();
  67.         $this->accessSites = new ArrayCollection();
  68.         $this->documents = new ArrayCollection();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getName(): ?string
  75.     {
  76.         return $this->name;
  77.     }
  78.     public function setName(string $name): self
  79.     {
  80.         $this->name $name;
  81.         return $this;
  82.     }
  83.     
  84.     public function getNumber(): ?string
  85.     {
  86.         return $this->number;
  87.     }
  88.     public function setNumber(?string $number): self
  89.     {
  90.         $this->number $number;
  91.         return $this;
  92.     }
  93.     public function getCreatedDate(): ?\DateTimeInterface
  94.     {
  95.         return $this->createdDate;
  96.     }
  97.    
  98.     public function getUpdatedDate(): ?\DateTimeInterface
  99.     {
  100.         return $this->updatedDate;
  101.     }
  102.     public function getStatus(): ?int
  103.     {
  104.         return $this->status;
  105.     }
  106.     public function setStatus(?int $status): self
  107.     {
  108.         $this->status $status;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return Collection|Participation[]
  113.      */
  114.     public function getParticipations(): Collection
  115.     {
  116.         return $this->participations;
  117.     }
  118.     public function addParticipation(Participation $participation): self
  119.     {
  120.         if (!$this->participations->contains($participation)) {
  121.             $this->participations[] = $participation;
  122.             $participation->setBoat($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removeParticipation(Participation $participation): self
  127.     {
  128.         if ($this->participations->contains($participation)) {
  129.             $this->participations->removeElement($participation);
  130.             // set the owning side to null (unless already changed)
  131.             if ($participation->getBoat() === $this) {
  132.                 $participation->setBoat(null);
  133.             }
  134.         }
  135.         return $this;
  136.     }
  137.     public function getClasse(): ?Classe
  138.     {
  139.         return $this->classe;
  140.     }
  141.     public function setClasse(?Classe $classe): self
  142.     {
  143.         $this->classe $classe;
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return Collection|AccessSite[]
  148.      */
  149.     public function getAccessSites(): Collection
  150.     {
  151.         return $this->accessSites;
  152.     }
  153.     public function addAccessSite(AccessSite $accessSite): self
  154.     {
  155.         if (!$this->accessSites->contains($accessSite)) {
  156.             $this->accessSites[] = $accessSite;
  157.             $accessSite->addBoat($this);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeAccessSite(AccessSite $accessSite): self
  162.     {
  163.         if ($this->accessSites->contains($accessSite)) {
  164.             $this->accessSites->removeElement($accessSite);
  165.             $accessSite->removeBoat($this);
  166.         }
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection|Document[]
  171.      */
  172.     public function getDocuments(): Collection
  173.     {
  174.         return $this->documents;
  175.     }
  176.     public function addDocument(Document $document): self
  177.     {
  178.         if (!$this->documents->contains($document)) {
  179.             $this->documents[] = $document;
  180.             $document->addBoat($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeDocument(Document $document): self
  185.     {
  186.         if ($this->documents->contains($document)) {
  187.             $this->documents->removeElement($document);
  188.             $document->removeBoat($this);
  189.         }
  190.         return $this;
  191.     }
  192.     public function __toString(): string
  193.     {
  194.         return $this->name $this->name '';
  195.     }
  196. }