src/Entity/Federation/Participation.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Federation;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use App\Entity\User\User;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\Federation\ParticipationRepository")
  12.  * @ORM\Table(name="participations")
  13.  * @UniqueEntity(fields={"boat", "race"}, message="participation.boat")
  14.  * @UniqueEntity(fields={"skipper", "race"}, message="participation.skipper")
  15.  */
  16. class Participation
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\Column(type="integer")
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity="App\Entity\Federation\Skipper", inversedBy="participations", cascade={"persist"})
  26.      * @ORM\JoinColumn(name="skipper_id", referencedColumnName="id")
  27.      * @Assert\NotBlank()
  28.      */
  29.     private $skipper;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity="App\Entity\Federation\Race", inversedBy="participations")
  32.      * @ORM\JoinColumn(name="race_id", referencedColumnName="id")
  33.      * @Assert\NotBlank()
  34.      */
  35.     private $race;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\Federation\Boat", inversedBy="participations", cascade={"persist"})
  38.      * @ORM\JoinColumn(name="boat_id", referencedColumnName="id")
  39.      * @Assert\NotBlank()
  40.      */
  41.     private $boat;
  42.     
  43.     /**
  44.      * @ORM\ManyToMany(targetEntity="App\Entity\User\User", inversedBy="participations"))
  45.      * @ORM\JoinTable(name="participations_referents")
  46.      * @ORM\JoinColumn(nullable=true)
  47.      */
  48.     private $referents;   
  49.     
  50.      /**
  51.      * @ORM\ManyToMany(targetEntity="App\Entity\Federation\Team", cascade={"persist"}, inversedBy="participations"))
  52.      * @ORM\JoinTable(name="participations_teams")
  53.      * @ORM\JoinColumn(nullable=true)
  54.      */
  55.     private $teams;
  56.     
  57.     /**
  58.      * @ORM\Column(type="datetime", nullable=false, name="created_date")
  59.      * @Gedmo\Timestampable(on="create")
  60.      */
  61.     private $createdDate;
  62.     
  63.     /**
  64.      * @ORM\Column(type="datetime", nullable=true, name="updated_date")
  65.      * @Gedmo\Timestampable(on="update")
  66.      */
  67.     private $updatedDate;
  68.     
  69.     /**
  70.      * @ORM\Column(type="integer", nullable=true, name="status")
  71.      */
  72.     private $status 1;
  73.     public function __construct()
  74.     {
  75.         $this->teams = new ArrayCollection(); 
  76.         $this->referents = new ArrayCollection(); 
  77.     }
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id
  81.     }
  82.     public function getCreatedDate(): ?\DateTimeInterface
  83.     {
  84.         return $this->createdDate;
  85.     }
  86.     
  87.     public function getUpdatedDate(): ?\DateTimeInterface
  88.     {
  89.         return $this->updatedDate;
  90.     }
  91.     public function getStatus(): ?int
  92.     {
  93.         return $this->status;
  94.     }
  95.     public function setStatus(?int $status): self
  96.     {
  97.         $this->status $status;
  98.         return $this;
  99.     }
  100.     public function getSkipper(): ?Skipper
  101.     {
  102.         return $this->skipper;
  103.     }
  104.     public function setSkipper(?Skipper $skipper): self
  105.     {
  106.         $this->skipper $skipper;
  107.         return $this;
  108.     }
  109.     public function getRace(): ?Race
  110.     {
  111.         return $this->race;
  112.     }
  113.     public function setRace(?Race $race): self
  114.     {
  115.         $this->race $race;
  116.         return $this;
  117.     }
  118.     public function getBoat(): ?Boat
  119.     {
  120.         return $this->boat;
  121.     }
  122.     public function setBoat(?Boat $boat): self
  123.     {
  124.         $this->boat $boat;
  125.         return $this;
  126.     }
  127.         
  128.     /**
  129.      * @return Collection|User[]
  130.      */
  131.     public function getReferents(): ?Collection
  132.     {
  133.         return $this->referents;
  134.     }
  135.     public function addReferent(User $referent): self
  136.     {
  137.         if (!$this->referents->contains($referent)) {
  138.             $this->referents[] = $referent;
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeReferent(User $referent): self
  143.     {
  144.         if ($this->referents->contains($referent)) {
  145.             $this->referents->removeElement($referent);
  146.         }
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return Collection|Team[]
  151.      */
  152.     public function getTeams(): Collection
  153.     {
  154.         return $this->teams;
  155.     }
  156.     public function addTeam(Team $team): self
  157.     {
  158.         if (!$this->teams->contains($team)) {
  159.             $this->teams[] = $team;
  160.         }
  161.         return $this;
  162.     }
  163.     public function removeTeam(Team $team): self
  164.     {
  165.         if ($this->teams->contains($team)) {
  166.             $this->teams->removeElement($team);
  167.         }
  168.         return $this;
  169.     }
  170. }