src/Entity/Game.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Locality;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\GameRepository")
  11.  * @Vich\Uploadable
  12.  */
  13. class Game
  14. {
  15.   /**
  16.    * @ORM\Id()
  17.    * @ORM\GeneratedValue()
  18.    * @ORM\Column(type="integer")
  19.    */
  20.   private $id;
  21.   /**
  22.    * @ORM\ManyToOne(targetEntity="App\Entity\Season", inversedBy="games")
  23.    * @ORM\JoinColumn(nullable=false)
  24.    */
  25.   private $season;
  26.   /**
  27.    * @ORM\Column(type="string", length=255)
  28.    */
  29.   private $rival;
  30.   /**
  31.    * @ORM\OneToOne(targetEntity=Locality::class)
  32.    */
  33.   private $locality;
  34.   /**
  35.    * @ORM\Column(type="integer")
  36.    */
  37.   private $day;
  38.   /**
  39.    * @ORM\Column(type="datetime")
  40.    */
  41.   private $date;
  42.   /**
  43.    * @ORM\Column(type="integer")
  44.    */
  45.   private $goals;
  46.   /**
  47.    * @ORM\Column(type="integer")
  48.    */
  49.   private $rivalGoals;
  50.   /**
  51.    * @ORM\Column(type="string", length=255, nullable=true)
  52.    */
  53.   private $image;
  54.   /**
  55.    * @Vich\UploadableField(mapping="game_images", fileNameProperty="image")
  56.    * @var File
  57.    */
  58.   private $imageFile;
  59.   /**
  60.    * @ORM\Column(type="datetime", nullable=true)
  61.    * @var \DateTime
  62.    */
  63.   private $updatedAt;
  64.   /**
  65.    * @ORM\OneToOne(targetEntity="App\Entity\Convocatoria", mappedBy="game", cascade={"persist", "remove"})
  66.    */
  67.   private $convocatoria;
  68.   /**
  69.    * @ORM\OneToMany(targetEntity=Minutes::class, mappedBy="game_id")
  70.    */
  71.   private $minutes;
  72.   /**
  73.    * @ORM\OneToOne(targetEntity=Competition::class)
  74.    */
  75.   private $competition;
  76.   /**
  77.    * @ORM\Column(type="integer")
  78.    */
  79.   private $shots_goal;
  80.   /**
  81.    * @ORM\Column(type="integer")
  82.    */
  83.   private $shots_opponent;
  84.   /**
  85.    * @ORM\Column(type="integer")
  86.    */
  87.   private $corners_favor;
  88.   /**
  89.    * @ORM\Column(type="integer")
  90.    */
  91.   private $corners_against;
  92.   /**
  93.    * @ORM\Column(type="integer")
  94.    */
  95.   private $penalties_favor;
  96.   /**
  97.    * @ORM\Column(type="integer")
  98.    */
  99.   private $penalties_against;
  100.   /**
  101.    * @ORM\Column(type="integer")
  102.    */
  103.   private $fouls_favor;
  104.   /**
  105.    * @ORM\Column(type="integer")
  106.    */
  107.   private $fouls_against;
  108.   /**
  109.    * @ORM\OneToOne(targetEntity=GameAlignment::class, inversedBy="game", cascade={"persist", "remove"})
  110.    */
  111.   private $alignment;
  112.   /**
  113.    * @ORM\Column(type="integer", options={"default" : 90})
  114.    */
  115.   private $timeMatch;
  116.   /**
  117.    * @ORM\Column(type="integer", options={"default" : 11})
  118.    */
  119.   private $category;
  120.   /**
  121.    * @ORM\OneToOne(targetEntity=GameAlignment::class, inversedBy="game", cascade={"persist", "remove"})
  122.    */
  123.   private $rival_alignment;
  124.   /**
  125.    * @ORM\Column(type="integer", options={"default" : 0})
  126.    */
  127.   private $total_shots;
  128.   /**
  129.    * @ORM\Column(type="integer", options={"default" : 0})
  130.    */
  131.   private $total_shots_against;
  132.   /**
  133.    * @ORM\Column(type="integer", options={"default" : 0})
  134.    */
  135.   private $yellow_cards;
  136.   /**
  137.    * @ORM\Column(type="integer", options={"default" : 0})
  138.    */
  139.   private $yellow_cards_against;
  140.   /**
  141.    * @ORM\Column(type="integer", options={"default" : 0})
  142.    */
  143.   private $red_cards;
  144.   /**
  145.    * @ORM\Column(type="integer", options={"default" : 0})
  146.    */
  147.   private $red_cards_against;
  148.   /**
  149.    * @ORM\Column(type="integer", options={"default" : 0})
  150.    */
  151.   private $currentPositionLeague;
  152.   /**
  153.    * @ORM\OneToMany(targetEntity=KilometersTraveled::class, mappedBy="game")
  154.    */
  155.   private $kilometersTraveleds;
  156.   /**
  157.    * @ORM\OneToMany(targetEntity=ShotsOnGoal::class, mappedBy="game")
  158.    */
  159.   private $shotsOnGoals;
  160.   /**
  161.    * @ORM\OneToMany(targetEntity=GamePlayerStatistics::class, mappedBy="game")
  162.    */
  163.   private $seasonplayer;
  164.   /**
  165.    * @ORM\OneToMany(targetEntity=GamePlayerStatistics::class, mappedBy="game")
  166.    */
  167.   private $gamePlayerStatistics;
  168.   /**
  169.    * @ORM\Column(type="integer", nullable=true)
  170.    */
  171.   private $opponentCurrentPositionLeague;
  172.   /**
  173.    * @ORM\ManyToOne(targetEntity=Difficulty::class, inversedBy="pressureRivals")
  174.    */
  175.   private $pressureRival;
  176.   /**
  177.    * @ORM\Column(type="datetime", nullable=true)
  178.    * @var \DateTime
  179.    */
  180.   private $deletedAt;
  181.   public function __construct()
  182.   {
  183.     $this->minutes = new ArrayCollection();
  184.     $this->kilometersTraveleds = new ArrayCollection();
  185.     $this->shotsOnGoals = new ArrayCollection();
  186.     $this->seasonplayer = new ArrayCollection();
  187.     $this->gamePlayerStatistics = new ArrayCollection();
  188.   }
  189.   public function getId(): ?int
  190.   {
  191.     return $this->id;
  192.   }
  193.   public function getSeason(): ?Season
  194.   {
  195.     return $this->season;
  196.   }
  197.   public function setSeason(?Season $season): self
  198.   {
  199.     $this->season $season;
  200.     return $this;
  201.   }
  202.   public function getRival(): ?string
  203.   {
  204.     return $this->rival;
  205.   }
  206.   public function setRival(string $rival): self
  207.   {
  208.     $this->rival $rival;
  209.     return $this;
  210.   }
  211.   public function getLocality(): ?Locality
  212.   {
  213.     return $this->locality;
  214.   }
  215.   public function setLocality(Locality $locality): self
  216.   {
  217.     $this->locality $locality;
  218.     return $this;
  219.   }
  220.   public function getDay(): ?int
  221.   {
  222.     return $this->day;
  223.   }
  224.   public function setDay(int $day): self
  225.   {
  226.     $this->day $day;
  227.     return $this;
  228.   }
  229.   public function getDate(): ?\DateTimeInterface
  230.   {
  231.     return $this->date;
  232.   }
  233.   public function setDate(\DateTimeInterface $date): self
  234.   {
  235.     $this->date $date;
  236.     return $this;
  237.   }
  238.   public function getGoals(): ?int
  239.   {
  240.     return $this->goals;
  241.   }
  242.   public function setGoals(int $goals): self
  243.   {
  244.     $this->goals $goals;
  245.     return $this;
  246.   }
  247.   public function getRivalGoals(): ?int
  248.   {
  249.     return $this->rivalGoals;
  250.   }
  251.   public function setRivalGoals(int $rivalGoals): self
  252.   {
  253.     $this->rivalGoals $rivalGoals;
  254.     return $this;
  255.   }
  256.   /**
  257.    * @return \DateTime
  258.    */
  259.   public function getUpdatedAt(): \DateTime
  260.   {
  261.     return $this->updatedAt;
  262.   }
  263.   /**
  264.    * @param \DateTime $updatedAt
  265.    * @return Game
  266.    */
  267.   public function setUpdatedAt(\DateTime $updatedAt): Game
  268.   {
  269.     $this->updatedAt $updatedAt;
  270.     return $this;
  271.   }
  272.   /**
  273.    * @param File|null $image
  274.    * @return Game
  275.    */
  276.   public function setImageFile(File $image null)
  277.   {
  278.     $this->imageFile $image;
  279.     // VERY IMPORTANT:
  280.     // It is required that at least one field changes if you are using Doctrine,
  281.     // otherwise the event listeners won't be called and the file is lost
  282.     if ($image) {
  283.       // if 'updatedAt' is not defined in your entity, use another property
  284.       $this->updatedAt = new \DateTime('now');
  285.     }
  286.     return $this;
  287.   }
  288.   public function getImageFile()
  289.   {
  290.     return $this->imageFile;
  291.   }
  292.   public function getImage(): ?string
  293.   {
  294.     return $this->image;
  295.   }
  296.   public function setImage(?string $image): self
  297.   {
  298.     $this->image $image;
  299.     return $this;
  300.   }
  301.   public function getConvocatoria(): ?Convocatoria
  302.   {
  303.     return $this->convocatoria;
  304.   }
  305.   public function setConvocatoria(Convocatoria $convocatoria): self
  306.   {
  307.     $this->convocatoria $convocatoria;
  308.     // set the owning side of the relation if necessary
  309.     if ($convocatoria->getGame() !== $this) {
  310.       $convocatoria->setGame($this);
  311.     }
  312.     return $this;
  313.   }
  314.   public function __toArray($imagePath)
  315.   {
  316.     return [
  317.       "id" => $this->getId(),
  318.       "rival" => $this->getRival(),
  319.       "locality" => $this->getLocality() ? $this->getLocality()->getName() : null,
  320.       "locality_id" => $this->getLocality() ? $this->getLocality()->getId() : null,
  321.       "day" => $this->getDay(),
  322.       "date" => $this->getDate()->format("d/m/Y H:i"),
  323.       "goals" => $this->getGoals(),
  324.       "rivalGoals" => $this->getRivalGoals(),
  325.       "image" => !empty($this->getImage()) ? $imagePath $this->getImage() : "",
  326.       "competition" => $this->getCompetition() ? $this->getCompetition()->getName() : null,
  327.       "competition_id" => $this->getCompetition() ? $this->getCompetition()->getId() : null,
  328.       "timeMatch" => $this->getTimeMatch(),
  329.       "category" => $this->getCategory(),
  330.       "shots_goal" => $this->getShotsGoal(),
  331.       "shots_opponent" => $this->getShotsOpponent(),
  332.       "corners_favor" => $this->getCornersFavor(),
  333.       "corners_against" => $this->getCornersAgainst(),
  334.       "penalties_favor" => $this->getPenaltiesFavor(),
  335.       "penalties_against" => $this->getPenaltiesAgainst(),
  336.       "fouls_favor" => $this->getFoulsFavor(),
  337.       "fouls_against" => $this->getFoulsAgainst(),
  338.       "rival_tactic" => $this->getRivalAlignment() != null $this->getRivalAlignment()->getTactic() : "",
  339.       'total_shots' => $this->getTotalShots() ?? 0,
  340.       'total_shots_against' => $this->getTotalShotsAgainst() ?? 0,
  341.       'yellow_cards' => $this->getYellowCards() ?? 0,
  342.       'yellow_cards_against' => $this->getYellowCardsAgainst() ?? 0,
  343.       'red_cards' => $this->getRedCards() ?? 0,
  344.       'opponentCurrentPositionLeague' => $this->getOpponentCurrentPositionLeague() ?? 0,
  345.       'pressureRival' => $this->getPressureRival() ? $this->getPressureRival()->__toArray() : null,
  346.       'pressureRivalId' => $this->getPressureRival() ? $this->getPressureRival()->getId() : null,
  347.       'red_cards_against' => $this->getRedCardsAgainst() ?? 0,
  348.       'alignment' => $this->getAlignment() ? $this->getAlignment()->__toArray() : null,
  349.       'currentPositionLeague' => $this->getCurrentPositionLeague()
  350.     ];
  351.   }
  352.   /**
  353.    * @return Collection|Minutes[]
  354.    */
  355.   public function getMinutes(): Collection
  356.   {
  357.     return $this->minutes;
  358.   }
  359.   public function addMinute(Minutes $minute): self
  360.   {
  361.     if (!$this->minutes->contains($minute)) {
  362.       $this->minutes[] = $minute;
  363.       $minute->setGameId($this);
  364.     }
  365.     return $this;
  366.   }
  367.   public function removeMinute(Minutes $minute): self
  368.   {
  369.     if ($this->minutes->contains($minute)) {
  370.       $this->minutes->removeElement($minute);
  371.       // set the owning side to null (unless already changed)
  372.       if ($minute->getGameId() === $this) {
  373.         $minute->setGameId(null);
  374.       }
  375.     }
  376.     return $this;
  377.   }
  378.   public function getShotsGoal(): ?int
  379.   {
  380.     return $this->shots_goal;
  381.   }
  382.   public function setShotsGoal(int $shots_goal): self
  383.   {
  384.     $this->shots_goal $shots_goal;
  385.     return $this;
  386.   }
  387.   public function getShotsOpponent(): ?int
  388.   {
  389.     return $this->shots_opponent;
  390.   }
  391.   public function setShotsOpponent(int $shots_opponent): self
  392.   {
  393.     $this->shots_opponent $shots_opponent;
  394.     return $this;
  395.   }
  396.   public function getCornersFavor(): ?int
  397.   {
  398.     return $this->corners_favor;
  399.   }
  400.   public function setCornersFavor(int $corners_favor): self
  401.   {
  402.     $this->corners_favor $corners_favor;
  403.     return $this;
  404.   }
  405.   public function getCornersAgainst(): ?int
  406.   {
  407.     return $this->corners_against;
  408.   }
  409.   public function setCornersAgainst(int $corners_against): self
  410.   {
  411.     $this->corners_against $corners_against;
  412.     return $this;
  413.   }
  414.   public function getPenaltiesFavor(): ?int
  415.   {
  416.     return $this->penalties_favor;
  417.   }
  418.   public function setPenaltiesFavor(int $penalties_favor): self
  419.   {
  420.     $this->penalties_favor $penalties_favor;
  421.     return $this;
  422.   }
  423.   public function getPenaltiesAgainst(): ?int
  424.   {
  425.     return $this->penalties_against;
  426.   }
  427.   public function setPenaltiesAgainst(int $penalties_against): self
  428.   {
  429.     $this->penalties_against $penalties_against;
  430.     return $this;
  431.   }
  432.   public function getFoulsFavor(): ?int
  433.   {
  434.     return $this->fouls_favor;
  435.   }
  436.   public function setFoulsFavor(int $fouls_favor): self
  437.   {
  438.     $this->fouls_favor $fouls_favor;
  439.     return $this;
  440.   }
  441.   public function getFoulsAgainst(): ?int
  442.   {
  443.     return $this->fouls_against;
  444.   }
  445.   public function setFoulsAgainst(int $fouls_against): self
  446.   {
  447.     $this->fouls_against $fouls_against;
  448.     return $this;
  449.   }
  450.   public function getAlignment(): ?GameAlignment
  451.   {
  452.     return $this->alignment;
  453.   }
  454.   public function setAlignment(?GameAlignment $alignment): self
  455.   {
  456.     $this->alignment $alignment;
  457.     return $this;
  458.   }
  459.   public function getTimeMatch(): ?int
  460.   {
  461.     return $this->timeMatch;
  462.   }
  463.   public function setTimeMatch(?int $timeMatch): self
  464.   {
  465.     $this->timeMatch $timeMatch;
  466.     return $this;
  467.   }
  468.   public function getCategory(): ?int
  469.   {
  470.     return $this->category;
  471.   }
  472.   public function setCategory(int $category): self
  473.   {
  474.     $this->category $category;
  475.     return $this;
  476.   }
  477.   public function getRivalAlignment(): ?GameAlignment
  478.   {
  479.     return $this->rival_alignment;
  480.   }
  481.   public function setRivalAlignment(?GameAlignment $alignment): self
  482.   {
  483.     $this->rival_alignment $alignment;
  484.     return $this;
  485.   }
  486.   public function getTotalShots(): ?int
  487.   {
  488.     return $this->total_shots;
  489.   }
  490.   public function setTotalShots(?int $total_shots): self
  491.   {
  492.     $this->total_shots $total_shots;
  493.     return $this;
  494.   }
  495.   public function getTotalShotsAgainst(): ?int
  496.   {
  497.     return $this->total_shots_against;
  498.   }
  499.   public function setTotalShotsAgainst(?int $total_shots_against): self
  500.   {
  501.     $this->total_shots_against $total_shots_against;
  502.     return $this;
  503.   }
  504.   public function getYellowCards(): ?int
  505.   {
  506.     return $this->yellow_cards;
  507.   }
  508.   public function setYellowCards(?int $yellow_cards): self
  509.   {
  510.     $this->yellow_cards $yellow_cards;
  511.     return $this;
  512.   }
  513.   public function getYellowCardsAgainst(): ?int
  514.   {
  515.     return $this->yellow_cards_against;
  516.   }
  517.   public function setYellowCardsAgainst(?int $yellow_cards_against): self
  518.   {
  519.     $this->yellow_cards_against $yellow_cards_against;
  520.     return $this;
  521.   }
  522.   public function getRedCards(): ?int
  523.   {
  524.     return $this->red_cards;
  525.   }
  526.   public function setRedCards(?int $red_cards): self
  527.   {
  528.     $this->red_cards $red_cards;
  529.     return $this;
  530.   }
  531.   public function getRedCardsAgainst(): ?int
  532.   {
  533.     return $this->red_cards_against;
  534.   }
  535.   public function setRedCardsAgainst(?int $red_cards_against): self
  536.   {
  537.     $this->red_cards_against $red_cards_against;
  538.     return $this;
  539.   }
  540.   public function getCurrentPositionLeague(): ?int
  541.   {
  542.     return $this->currentPositionLeague;
  543.   }
  544.   public function setCurrentPositionLeague(?int $currentPositionLeague): self
  545.   {
  546.     $this->currentPositionLeague $currentPositionLeague;
  547.     return $this;
  548.   }
  549.   /**
  550.    * @return Collection|KilometersTraveled[]
  551.    */
  552.   public function getKilometersTraveleds(): Collection
  553.   {
  554.     return $this->kilometersTraveleds;
  555.   }
  556.   public function addKilometersTraveled(KilometersTraveled $kilometersTraveled): self
  557.   {
  558.     if (!$this->kilometersTraveleds->contains($kilometersTraveled)) {
  559.       $this->kilometersTraveleds[] = $kilometersTraveled;
  560.       $kilometersTraveled->setGame($this);
  561.     }
  562.     return $this;
  563.   }
  564.   public function removeKilometersTraveled(KilometersTraveled $kilometersTraveled): self
  565.   {
  566.     if ($this->kilometersTraveleds->contains($kilometersTraveled)) {
  567.       $this->kilometersTraveleds->removeElement($kilometersTraveled);
  568.       // set the owning side to null (unless already changed)
  569.       if ($kilometersTraveled->getGame() === $this) {
  570.         $kilometersTraveled->setGame(null);
  571.       }
  572.     }
  573.     return $this;
  574.   }
  575.   /**
  576.    * @return Collection|ShotsOnGoal[]
  577.    */
  578.   public function getShotsOnGoals(): Collection
  579.   {
  580.     return $this->shotsOnGoals;
  581.   }
  582.   public function addShotsOnGoal(ShotsOnGoal $shotsOnGoal): self
  583.   {
  584.     if (!$this->shotsOnGoals->contains($shotsOnGoal)) {
  585.       $this->shotsOnGoals[] = $shotsOnGoal;
  586.       $shotsOnGoal->setGame($this);
  587.     }
  588.     return $this;
  589.   }
  590.   public function removeShotsOnGoal(ShotsOnGoal $shotsOnGoal): self
  591.   {
  592.     if ($this->shotsOnGoals->contains($shotsOnGoal)) {
  593.       $this->shotsOnGoals->removeElement($shotsOnGoal);
  594.       // set the owning side to null (unless already changed)
  595.       if ($shotsOnGoal->getGame() === $this) {
  596.         $shotsOnGoal->setGame(null);
  597.       }
  598.     }
  599.     return $this;
  600.   }
  601.   /**
  602.    * @return Collection|GamePlayerStatistics[]
  603.    */
  604.   public function getSeasonplayer(): Collection
  605.   {
  606.     return $this->seasonplayer;
  607.   }
  608.   public function addSeasonplayer(GamePlayerStatistics $seasonplayer): self
  609.   {
  610.     if (!$this->seasonplayer->contains($seasonplayer)) {
  611.       $this->seasonplayer[] = $seasonplayer;
  612.       $seasonplayer->setGame($this);
  613.     }
  614.     return $this;
  615.   }
  616.   public function removeSeasonplayer(GamePlayerStatistics $seasonplayer): self
  617.   {
  618.     if ($this->seasonplayer->contains($seasonplayer)) {
  619.       $this->seasonplayer->removeElement($seasonplayer);
  620.       // set the owning side to null (unless already changed)
  621.       if ($seasonplayer->getGame() === $this) {
  622.         $seasonplayer->setGame(null);
  623.       }
  624.     }
  625.     return $this;
  626.   }
  627.   /**
  628.    * @return Collection|GamePlayerStatistics[]
  629.    */
  630.   public function getGamePlayerStatistics(): Collection
  631.   {
  632.     return $this->gamePlayerStatistics;
  633.   }
  634.   public function addGamePlayerStatistic(GamePlayerStatistics $gamePlayerStatistic): self
  635.   {
  636.     if (!$this->gamePlayerStatistics->contains($gamePlayerStatistic)) {
  637.       $this->gamePlayerStatistics[] = $gamePlayerStatistic;
  638.       $gamePlayerStatistic->setGame($this);
  639.     }
  640.     return $this;
  641.   }
  642.   public function removeGamePlayerStatistic(GamePlayerStatistics $gamePlayerStatistic): self
  643.   {
  644.     if ($this->gamePlayerStatistics->contains($gamePlayerStatistic)) {
  645.       $this->gamePlayerStatistics->removeElement($gamePlayerStatistic);
  646.       // set the owning side to null (unless already changed)
  647.       if ($gamePlayerStatistic->getGame() === $this) {
  648.         $gamePlayerStatistic->setGame(null);
  649.       }
  650.     }
  651.     return $this;
  652.   }
  653.   public function getCompetition(): ?Competition
  654.   {
  655.     return $this->competition;
  656.   }
  657.   public function setCompetition(?Competition $competition): self
  658.   {
  659.     $this->competition $competition;
  660.     return $this;
  661.   }
  662.   public function getOpponentCurrentPositionLeague(): ?int
  663.   {
  664.     return $this->opponentCurrentPositionLeague;
  665.   }
  666.   public function setOpponentCurrentPositionLeague(?int $opponentCurrentPositionLeague): self
  667.   {
  668.     $this->opponentCurrentPositionLeague $opponentCurrentPositionLeague;
  669.     return $this;
  670.   }
  671.   public function getPressureRival(): ?Difficulty
  672.   {
  673.     return $this->pressureRival;
  674.   }
  675.   public function setPressureRival(?Difficulty $pressureRival): self
  676.   {
  677.     $this->pressureRival $pressureRival;
  678.     return $this;
  679.   }
  680.   public function getDeletedAt(): ?\DateTimeInterface
  681.   {
  682.     return $this->deletedAt;
  683.   }
  684.   public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  685.   {
  686.     $this->deletedAt $deletedAt;
  687.     return $this;
  688.   }
  689. }