src/Entity/Club/Club.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Club;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. /**
  7.  * Club
  8.  *
  9.  * @ORM\Table(name="tam_clubs")
  10.  * @ORM\Entity(repositoryClass="App\Repository\Club\ClubRepository")
  11.  * @ORM\HasLifecycleCallbacks
  12.  */
  13. class Club
  14. {
  15.     /**
  16.      * @var int
  17.      *
  18.      * @ORM\Column(name="id", type="integer")
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue(strategy="IDENTITY")
  21.      */
  22.     private $id;
  23.     
  24.     /**
  25.      * @ORM\OneToOne(targetEntity="App\Entity\User", inversedBy="club", cascade={"persist", "remove"})
  26.      * @ORM\JoinColumn(name="tam_user", referencedColumnName="id", onDelete="CASCADE", nullable=false)
  27.      */
  28.     private $user;
  29.     
  30.     /**
  31.      * @var string
  32.      *
  33.      * @ORM\Column(name="website", type="string", length=255, nullable=true)
  34.      */
  35.     private $website;
  36.     
  37.     /**
  38.      * @var string
  39.      *
  40.      * @ORM\Column(name="phone", type="string", length=255, nullable=true)
  41.      */
  42.     private $phone;
  43.     
  44.     /**
  45.      * @var integer
  46.      *
  47.      * @ORM\Column(name="nbcourt", type="integer", nullable=true)
  48.      */
  49.     private $nbCourt;
  50.     
  51.     /**
  52.      * @var string
  53.      *
  54.      * @ORM\Column(name="contact_name", type="string", length=255, nullable=true)
  55.      */
  56.     private $contactName;
  57.     
  58.     /**
  59.      * @var string
  60.      *
  61.      * @ORM\Column(name="contact_phone", type="string", length=255, nullable=true)
  62.      */
  63.     private $contactPhone;
  64.     
  65.     /**
  66.      * @var string
  67.      *
  68.      * @ORM\Column(name="contact_email", type="string", length=255, nullable=true)
  69.      */
  70.     private $contactEmail;
  71.     
  72.     /**
  73.      * @var string
  74.      *
  75.      * @ORM\Column(name="description", type="text", length=255, nullable=true)
  76.      */
  77.     private $description;
  78.     
  79.     /**
  80.      * @var boolean
  81.      *
  82.      * @ORM\Column(name="clubhouse", type="boolean", options={"default": FALSE})
  83.      */
  84.     private $clubhouse;
  85.     
  86.     /**
  87.      * @var boolean
  88.      *
  89.      * @ORM\Column(name="restaurant", type="boolean", options={"default": FALSE})
  90.      */
  91.     private $restaurant;
  92.     
  93.     /**
  94.      * @var boolean
  95.      *
  96.      * @ORM\Column(name="reception_tam_player", type="boolean", options={"default": FALSE})
  97.      */
  98.     private $receptionTamPlayer;
  99.     
  100.     /**
  101.      * @var float
  102.      *
  103.      * @ORM\Column(name="price_session_tam", type="float", precision=10, scale=0, nullable=true)
  104.      */
  105.     private $priceSessionTam;
  106.     
  107.     /**
  108.      * @var integer
  109.      *
  110.      * @ORM\Column(name="nb_licensee", type="integer", nullable=true)
  111.      */
  112.     private $nbLicensee;
  113.     
  114.     /**
  115.      * @var integer
  116.      *
  117.      * @ORM\Column(name="nb_licensee_under_eighteen", type="integer", nullable=true)
  118.      */
  119.     private $nbLicenseeUnderEighteen;
  120.     
  121.     /**
  122.      * @var integer
  123.      *
  124.      * @ORM\Column(name="year_created", type="integer", nullable=true)
  125.      */
  126.     private $yearCreated;
  127.     
  128.     /**
  129.      * @var boolean
  130.      *
  131.      * @ORM\Column(name="distributor_gc", type="boolean", options={"default": FALSE})
  132.      */
  133.     private $distributorGc;
  134.     
  135.     /**
  136.      * @var boolean
  137.      *
  138.      * @ORM\Column(name="distributor_ch", type="boolean", options={"default": FALSE})
  139.      */
  140.     private $distributorCh;
  141.     
  142.     /**
  143.      * @var \DateTime
  144.      *
  145.      * @ORM\Column(name="date_ask_access", type="datetime", nullable=true)
  146.      */
  147.     private $dateAskAccess;
  148.     
  149.     /**
  150.      * @var \DateTime
  151.      *
  152.      * @ORM\Column(name="date_ask_access_granted", type="datetime", nullable=true)
  153.      */
  154.     private $dateAskAccessGranted;
  155.     
  156.     /**
  157.      * @var ArrayCollection
  158.      *
  159.      * @ORM\OneToMany(targetEntity="App\Entity\Club\ClubSurface", mappedBy="club", cascade={"persist", "remove"})
  160.      */
  161.     private $clubSurfaces;
  162.     
  163.     /**
  164.      * @var ArrayCollection $players
  165.      *
  166.      * @ORM\OneToMany(targetEntity="\App\Entity\Player\Player", mappedBy="club")
  167.      */
  168.     private $players;
  169.     
  170.     /**
  171.      * @var ArrayCollection
  172.      *
  173.      * @ORM\OneToMany(targetEntity="\App\Entity\Event\EventClub", mappedBy="club", cascade={"persist", "remove"})
  174.      */
  175.     private $events;
  176.     
  177.     /**
  178.      * @var ArrayCollection
  179.      *
  180.      * @ORM\OneToMany(targetEntity="\App\Entity\Tam\Tam", mappedBy="club", cascade={"persist", "remove"})
  181.      */
  182.     private $tams;
  183.     
  184.     
  185.     public function __construct()
  186.     {
  187.         $this->clubSurfaces = new ArrayCollection();
  188.         $this->players = new ArrayCollection();
  189.         $this->events = new ArrayCollection();
  190.         $this->tams = new ArrayCollection();
  191.         $this->clubhouse false;
  192.         $this->restaurant false;
  193.         $this->receptionTamPlayer false;
  194.         $this->distributorGc false;
  195.         $this->distributorCh false;
  196.     }
  197.     /**
  198.      * Get id
  199.      *
  200.      * @return int
  201.      */
  202.     public function getId()
  203.     {
  204.         return $this->id;
  205.     }
  206.     
  207.     /**
  208.      * Set User
  209.      *
  210.      * @param \App\Entity\User $user
  211.      *
  212.      * @return Club
  213.      */
  214.     public function setUser(\App\Entity\User $user)
  215.     {
  216.         $this->user $user;
  217.         $user->setClub($this);
  218.         return $this;
  219.     }
  220.     /**
  221.      * Get user
  222.      *
  223.      * @return \App\Entity\User
  224.      */
  225.     public function getUser()
  226.     {
  227.         return $this->user;
  228.     }
  229.     
  230.     /**
  231.      * Set website
  232.      *
  233.      * @param string $website
  234.      *
  235.      * @return Club
  236.      */
  237.     public function setWebsite($website)
  238.     {
  239.         $this->website strtolower($website);
  240.         return $this;
  241.     }
  242.     /**
  243.      * Get website
  244.      *
  245.      * @return string
  246.      */
  247.     public function getWebsite()
  248.     {
  249.         return $this->website;
  250.     }
  251.     
  252.     /**
  253.      * Set phone
  254.      *
  255.      * @param string $phone
  256.      *
  257.      * @return Club
  258.      */
  259.     public function setPhone($phone)
  260.     {
  261.         $this->phone $phone;
  262.         return $this;
  263.     }
  264.     /**
  265.      * Get phone
  266.      *
  267.      * @return string
  268.      */
  269.     public function getPhone()
  270.     {
  271.         return $this->phone;
  272.     }
  273.     
  274.     /**
  275.      * Set nbCourt
  276.      *
  277.      * @param integer $nbCourt
  278.      *
  279.      * @return Club
  280.      */
  281.     public function setNbCourt($nbCourt)
  282.     {
  283.         $this->nbCourt $nbCourt;
  284.         return $this;
  285.     }
  286.     /**
  287.      * Get nbCourt
  288.      *
  289.      * @return integer
  290.      */
  291.     public function getNbCourt()
  292.     {
  293.         return $this->nbCourt;
  294.     }
  295.     
  296.     /**
  297.      * Set contactName
  298.      *
  299.      * @param string $contactName
  300.      *
  301.      * @return Club
  302.      */
  303.     public function setContactName($contactName)
  304.     {
  305.         $this->contactName $contactName;
  306.         return $this;
  307.     }
  308.     /**
  309.      * Get contactName
  310.      *
  311.      * @return string
  312.      */
  313.     public function getContactName()
  314.     {
  315.         return $this->contactName;
  316.     }
  317.     
  318.     /**
  319.      * Set contactPhone
  320.      *
  321.      * @param string $contactPhone
  322.      *
  323.      * @return Club
  324.      */
  325.     public function setContactPhone($contactPhone)
  326.     {
  327.         $this->contactPhone $contactPhone;
  328.         return $this;
  329.     }
  330.     /**
  331.      * Get contactPhone
  332.      *
  333.      * @return string
  334.      */
  335.     public function getContactPhone()
  336.     {
  337.         return $this->contactPhone;
  338.     }
  339.     
  340.     /**
  341.      * Set contactEmail
  342.      *
  343.      * @param string $contactEmail
  344.      *
  345.      * @return Club
  346.      */
  347.     public function setContactEmail($contactEmail)
  348.     {
  349.         $this->contactEmail $contactEmail;
  350.         return $this;
  351.     }
  352.     /**
  353.      * Get contactEmail
  354.      *
  355.      * @return string
  356.      */
  357.     public function getContactEmail()
  358.     {
  359.         return $this->contactEmail;
  360.     }
  361.     
  362.     /**
  363.      * Set description
  364.      *
  365.      * @param string $description
  366.      *
  367.      * @return Club
  368.      */
  369.     public function setDescription($description)
  370.     {
  371.         $this->description $description;
  372.         return $this;
  373.     }
  374.     /**
  375.      * Get description
  376.      *
  377.      * @return string
  378.      */
  379.     public function getDescription()
  380.     {
  381.         return $this->description;
  382.     }
  383.     
  384.     /**
  385.      * Set clubhouse
  386.      *
  387.      * @param boolean $clubhouse
  388.      *
  389.      * @return Club
  390.      */
  391.     public function setClubhouse($clubhouse)
  392.     {
  393.         $this->clubhouse $clubhouse;
  394.         return $this;
  395.     }
  396.     /**
  397.      * Get clubhouse
  398.      *
  399.      * @return boolean
  400.      */
  401.     public function getClubhouse()
  402.     {
  403.         return $this->clubhouse;
  404.     }
  405.     
  406.     /**
  407.      * Have clubhouse
  408.      *
  409.      * @return boolean
  410.      */
  411.     public function haveClubhouse()
  412.     {
  413.         return $this->clubhouse;
  414.     }
  415.     
  416.     /**
  417.      * Set restaurant
  418.      *
  419.      * @param boolean $restaurant
  420.      *
  421.      * @return Club
  422.      */
  423.     public function setRestaurant($restaurant)
  424.     {
  425.         $this->restaurant $restaurant;
  426.         return $this;
  427.     }
  428.     /**
  429.      * Get restaurant
  430.      *
  431.      * @return boolean
  432.      */
  433.     public function getRestaurant()
  434.     {
  435.         return $this->restaurant;
  436.     }
  437.     
  438.     /**
  439.      * Have restaurant
  440.      *
  441.      * @return boolean
  442.      */
  443.     public function haveRestaurant()
  444.     {
  445.         return $this->restaurant;
  446.     }
  447.     
  448.     /**
  449.      * Set receptionTamPlayer
  450.      *
  451.      * @param boolean $receptionTamPlayer
  452.      *
  453.      * @return Club
  454.      */
  455.     public function setReceptionTamPlayer($receptionTamPlayer)
  456.     {
  457.         $this->receptionTamPlayer $receptionTamPlayer;
  458.         return $this;
  459.     }
  460.     /**
  461.      * Get receptionTamPlayer
  462.      *
  463.      * @return boolean
  464.      */
  465.     public function getReceptionTamPlayer()
  466.     {
  467.         return $this->receptionTamPlayer;
  468.     }
  469.     
  470.     /**
  471.      * Set priceSessionTam
  472.      *
  473.      * @param float $priceSessionTam
  474.      *
  475.      * @return Club
  476.      */
  477.     public function setPriceSessionTam($priceSessionTam)
  478.     {
  479.         if($priceSessionTam == "")
  480.             $this->priceSessionTam null;
  481.         else
  482.             $this->priceSessionTam str_replace(",""."$priceSessionTam);
  483.         return $this;
  484.     }
  485.     /**
  486.      * Get priceSessionTam
  487.      *
  488.      * @return float
  489.      */
  490.     public function getPriceSessionTam()
  491.     {
  492.         return $this->priceSessionTam;
  493.     }
  494.     
  495.     /**
  496.      * Set nbLicensee
  497.      *
  498.      * @param integer $nbLicensee
  499.      *
  500.      * @return Club
  501.      */
  502.     public function setNbLicensee($nbLicensee)
  503.     {
  504.         $this->nbLicensee $nbLicensee;
  505.         return $this;
  506.     }
  507.     /**
  508.      * Get nbLicensee
  509.      *
  510.      * @return integer
  511.      */
  512.     public function getNbLicensee()
  513.     {
  514.         return $this->nbLicensee;
  515.     }
  516.     
  517.     /**
  518.      * Set nbLicenseeUnderEighteen
  519.      *
  520.      * @param integer $nbLicenseeUnderEighteen
  521.      *
  522.      * @return Club
  523.      */
  524.     public function setNbLicenseeUnderEighteen($nbLicenseeUnderEighteen)
  525.     {
  526.         $this->nbLicenseeUnderEighteen $nbLicenseeUnderEighteen;
  527.         return $this;
  528.     }
  529.     /**
  530.      * Get nbLicenseeUnderEighteen
  531.      *
  532.      * @return integer
  533.      */
  534.     public function getNbLicenseeUnderEighteen()
  535.     {
  536.         return $this->nbLicenseeUnderEighteen;
  537.     }
  538.     
  539.     /**
  540.      * Set yearCreated
  541.      *
  542.      * @param integer $yearCreated
  543.      *
  544.      * @return Club
  545.      */
  546.     public function setYearCreated($yearCreated)
  547.     {
  548.         $this->yearCreated $yearCreated;
  549.         return $this;
  550.     }
  551.     /**
  552.      * Get yearCreated
  553.      *
  554.      * @return integer
  555.      */
  556.     public function getYearCreated()
  557.     {
  558.         return $this->yearCreated;
  559.     }
  560.     
  561.     /**
  562.      * Set distributorGc
  563.      *
  564.      * @param boolean $distributorGc
  565.      *
  566.      * @return Club
  567.      */
  568.     public function setDistributorGc($distributorGc)
  569.     {
  570.         $this->distributorGc $distributorGc;
  571.         return $this;
  572.     }
  573.     /**
  574.      * Get distributorGc
  575.      *
  576.      * @return boolean
  577.      */
  578.     public function getDistributorGc()
  579.     {
  580.         return $this->distributorGc;
  581.     }
  582.     
  583.     /**
  584.      * Set distributorCh
  585.      *
  586.      * @param boolean $distributorCh
  587.      *
  588.      * @return Club
  589.      */
  590.     public function setDistributorCh($distributorCh)
  591.     {
  592.         $this->distributorCh $distributorCh;
  593.         return $this;
  594.     }
  595.     /**
  596.      * Get distributorCh
  597.      *
  598.      * @return boolean
  599.      */
  600.     public function getDistributorCh()
  601.     {
  602.         return $this->distributorCh;
  603.     }
  604.     
  605.     /**
  606.      * Set dateAskAccess
  607.      *
  608.      * @param \DateTime $dateAskAccess
  609.      *
  610.      * @return Club
  611.      */
  612.     public function setDateAskAccess($dateAskAccess)
  613.     {
  614.         $this->dateAskAccess $dateAskAccess;
  615.         return $this;
  616.     }
  617.     /**
  618.      * Get dateAskAccess
  619.      *
  620.      * @return \DateTime
  621.      */
  622.     public function getDateAskAccess()
  623.     {
  624.         return $this->dateAskAccess;
  625.     }
  626.     
  627.     /**
  628.      * Set dateAskAccessGranted
  629.      *
  630.      * @param \DateTime $dateAskAccessGranted
  631.      *
  632.      * @return Club
  633.      */
  634.     public function setDateAskAccessGranted($dateAskAccessGranted)
  635.     {
  636.         $this->dateAskAccessGranted $dateAskAccessGranted;
  637.         return $this;
  638.     }
  639.     /**
  640.      * Get dateAskAccessGranted
  641.      *
  642.      * @return \DateTime
  643.      */
  644.     public function getDateAskAccessGranted()
  645.     {
  646.         return $this->dateAskAccessGranted;
  647.     }
  648.         
  649.     
  650.     /**
  651.      * Add clubSurface
  652.      *
  653.      * @param \App\Entity\Club\ClubSurface $clubSurface
  654.      *
  655.      * @return Club
  656.      */
  657.     public function addClubSurface(\App\Entity\Club\ClubSurface $clubSurface)
  658.     {
  659.         $clubSurface->setClub($this);
  660.         $this->clubSurfaces[] = $clubSurface;
  661.         return $this;
  662.     }
  663.     /**
  664.      * Remove clubSurface
  665.      *
  666.      * @param \App\Entity\Club\ClubSurface $clubSurface
  667.      */
  668.     public function removeClubSurface(\App\Entity\Club\ClubSurface $clubSurface)
  669.     {
  670.         $this->clubSurfaces->removeElement($clubSurface);
  671.     }
  672.     /**
  673.      * Get clubSurfaces
  674.      *
  675.      * @return \Doctrine\Common\Collections\Collection
  676.      */
  677.     public function getClubSurfaces()
  678.     {
  679.         return $this->clubSurfaces;
  680.     }
  681.     
  682.     
  683.     /**
  684.      * Add player
  685.      *
  686.      * @param \App\Entity\Player\Player $player
  687.      *
  688.      * @return Club
  689.      */
  690.     public function addPlayer(\App\Entity\Player\Player $player)
  691.     {
  692.         $this->players[] = $player;
  693.         return $this;
  694.     }
  695.     /**
  696.      * Remove player
  697.      *
  698.      * @param \App\Entity\Player\Player $player
  699.      */
  700.     public function removePlayer(\App\Entity\Player\Player $player)
  701.     {
  702.         $this->players->removeElement($player);
  703.     }
  704.     /**
  705.      * Get players
  706.      *
  707.      * @return \Doctrine\Common\Collections\Collection
  708.      */
  709.     public function getPlayers()
  710.     {
  711.         return $this->players;
  712.     }
  713.     
  714.     /**
  715.      * Add event
  716.      *
  717.      * @param \App\Entity\Event\EventClub $event
  718.      *
  719.      * @return Club
  720.      */
  721.     public function addEvent(\App\Entity\Event\EventClub $event)
  722.     {
  723.         $this->events[] = $event;
  724.         return $this;
  725.     }
  726.     /**
  727.      * Remove event
  728.      *
  729.      * @param \App\Entity\Event\EventClub $event
  730.      */
  731.     public function removeEvent(\App\Entity\Event\EventClub $event)
  732.     {
  733.         $this->events->removeElement($event);
  734.     }
  735.     /**
  736.      * Get events
  737.      *
  738.      * @return \Doctrine\Common\Collections\Collection
  739.      */
  740.     public function getEvents()
  741.     {
  742.         return $this->events;
  743.     }
  744.     
  745.     /**
  746.      * Add tam
  747.      *
  748.      * @param \App\Entity\Tam\Tam $tam
  749.      *
  750.      * @return Club
  751.      */
  752.     public function addTam(\App\Entity\Tam\Tam $tam)
  753.     {
  754.         $this->tams[] = $tam;
  755.         return $this;
  756.     }
  757.     /**
  758.      * Remove tam
  759.      *
  760.      * @param \App\Entity\Tam\Tam $tam
  761.      */
  762.     public function removeTam(\App\Entity\Tam\Tam $tam)
  763.     {
  764.         $this->tams->removeElement($tam);
  765.     }
  766.     /**
  767.      * Get tams
  768.      *
  769.      * @return \Doctrine\Common\Collections\Collection
  770.      */
  771.     public function getTams()
  772.     {
  773.         return $this->tams;
  774.     }
  775.     
  776.     
  777.     /***********************
  778.      * OTHER FUNCTION
  779.      ***********************/
  780.      
  781.      public function updateFromJson($jsonObject){
  782.         if(isset($jsonObject->description)){
  783.             $this->setDescription($jsonObject->description);
  784.         }
  785.         
  786.         if(isset($jsonObject->phone)){
  787.             $this->setPhone($jsonObject->phone);
  788.         }
  789.         
  790.         if(isset($jsonObject->website)){
  791.             $this->setWebsite($jsonObject->website);
  792.         }
  793.         
  794.         if(isset($jsonObject->contactName)){
  795.             $this->setContactName($jsonObject->contactName);
  796.         }
  797.         
  798.         if(isset($jsonObject->contactEmail)){
  799.             $this->setContactEmail($jsonObject->contactEmail);
  800.         }
  801.         
  802.         if(isset($jsonObject->contactPhone)){
  803.             $this->setContactPhone($jsonObject->contactPhone);
  804.         }
  805.         
  806.         if(isset($jsonObject->nbLicensee)){
  807.             $this->setNbLicensee($jsonObject->nbLicensee);
  808.         }
  809.         
  810.         if(isset($jsonObject->clubHouse)){
  811.             $this->setClubhouse($jsonObject->clubHouse);
  812.         }
  813.         
  814.         if(isset($jsonObject->restaurant)){
  815.             $this->setRestaurant($jsonObject->restaurant);
  816.         }
  817.         
  818.         if(isset($jsonObject->receptionTamPlayer)){
  819.             $this->setReceptionTamPlayer($jsonObject->receptionTamPlayer);
  820.         }
  821.         
  822.         
  823.     }
  824.     
  825.     public function getArrayForJson(){
  826.         $array = array();
  827.         $array['id'] = $this->getId();
  828.         $array['website'] = $this->getWebsite();
  829.         $array['phone'] = $this->getPhone();
  830.         $array['nbCourt'] = $this->getNbCourt();
  831.         $array['contactName'] = $this->getContactName();
  832.         $array['contactPhone'] = $this->getContactPhone();
  833.         $array['contactEmail'] = $this->getContactEmail();
  834.         $array['description'] = $this->getDescription();
  835.         $array['clubHouse'] = $this->getClubhouse();
  836.         $array['restaurant'] = $this->getRestaurant();
  837.         $array['receptionTamPlayer'] = $this->getReceptionTamPlayer();
  838.         $array['priceSessionTam'] = $this->getPriceSessionTam();
  839.         $array['nbLicensee'] = $this->getNbLicensee();
  840.         $array['nbLicenseeUnderEighteen'] = $this->getNbLicenseeUnderEighteen();
  841.         $array['yearCreated'] = $this->getYearCreated();
  842.         
  843.         foreach($this->getClubSurfaces() as $surface){
  844.             $array['surfaces'][] = $surface->getArrayForJson();
  845.         }
  846.         
  847.         return $array;
  848.         
  849.     }
  850.     
  851. }