src/Entity/Pro/Pro.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Pro;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. /**
  7.  * Pro
  8.  *
  9.  * @ORM\Table(name="tam_pros")
  10.  * @ORM\Entity(repositoryClass="App\Repository\Pro\ProRepository")
  11.  * @ORM\HasLifecycleCallbacks
  12.  */
  13. class Pro
  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="pro", cascade={"persist", "remove"})
  26.      * @ORM\JoinColumn(name="tam_user", referencedColumnName="id", onDelete="CASCADE", nullable=false)
  27.      */
  28.     private $user;
  29.     
  30.     /**
  31.      * @var \ProType
  32.      *
  33.      * @ORM\ManyToOne(targetEntity="\App\Entity\Pro\ProType", inversedBy="pros")
  34.      * @ORM\JoinColumns({
  35.      *   @ORM\JoinColumn(name="type_pro", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  36.      * })
  37.      */
  38.     private $typePro;
  39.     
  40.     /**
  41.      * @var string
  42.      *
  43.      * @ORM\Column(name="website", type="string", length=255, nullable=true)
  44.      */
  45.     private $website;
  46.     
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="phone", type="string", length=255, nullable=true)
  51.      */
  52.     private $phone;
  53.     
  54.     /**
  55.      * @var string
  56.      *
  57.      * @ORM\Column(name="description", type="text", length=255, nullable=true)
  58.      */
  59.     private $description;
  60.     
  61.     /**
  62.      * @var boolean
  63.      *
  64.      * @ORM\Column(name="distributor_gc", type="boolean", options={"default": FALSE})
  65.      */
  66.     private $distributorGc;
  67.     
  68.     /**
  69.      * @var boolean
  70.      *
  71.      * @ORM\Column(name="distributor_ch", type="boolean", options={"default": FALSE})
  72.      */
  73.     private $distributorCh;
  74.     
  75.     /**
  76.      * @var \DateTime
  77.      *
  78.      * @ORM\Column(name="date_ask_access", type="datetime", nullable=true)
  79.      */
  80.     private $dateAskAccess;
  81.     
  82.     /**
  83.      * @var \DateTime
  84.      *
  85.      * @ORM\Column(name="date_ask_access_granted", type="datetime", nullable=true)
  86.      */
  87.     private $dateAskAccessGranted;
  88.     
  89.     /**
  90.      * @var \DateTime
  91.      *
  92.      * @ORM\Column(name="date_signin", type="datetime", nullable=true)
  93.      */
  94.     private $dateSignin;
  95.     
  96.     /**
  97.      * @var ArrayCollection $openingHours
  98.      *
  99.      * @ORM\OneToMany(targetEntity="\App\Entity\Pro\OpeningHour", mappedBy="pro", cascade={"persist", "remove"})
  100.      * @ORM\OrderBy({"day" = "ASC"})
  101.      */
  102.     private $openingHours;
  103.     
  104.     
  105.     public function __construct()
  106.     {
  107.         $this->distributorGc false;
  108.         $this->distributorCh false;
  109.         $this->openingHours = new ArrayCollection();
  110.     }
  111.     /**
  112.      * Get id
  113.      *
  114.      * @return int
  115.      */
  116.     public function getId()
  117.     {
  118.         return $this->id;
  119.     }
  120.     
  121.     /**
  122.      * Set User
  123.      *
  124.      * @param \App\Entity\User $user
  125.      *
  126.      * @return Pro
  127.      */
  128.     public function setUser(\App\Entity\User $user)
  129.     {
  130.         $this->user $user;
  131.         return $this;
  132.     }
  133.     /**
  134.      * Get user
  135.      *
  136.      * @return \App\Entity\User
  137.      */
  138.     public function getUser()
  139.     {
  140.         return $this->user;
  141.     }
  142.     
  143.     /**
  144.      * Set typePro
  145.      *
  146.      * @param \App\Entity\Pro\proType $typePro
  147.      *
  148.      * @return Pro
  149.      */
  150.     public function setTypePro(\App\Entity\Pro\ProType $typePro)
  151.     {
  152.         $this->typePro $typePro;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get typePro
  157.      *
  158.      * @return \App\Entity\Pro\ProType
  159.      */
  160.     public function getTypePro()
  161.     {
  162.         return $this->typePro;
  163.     }
  164.     
  165.     /**
  166.      * Set website
  167.      *
  168.      * @param string $website
  169.      *
  170.      * @return Pro
  171.      */
  172.     public function setWebsite($website)
  173.     {
  174.         $this->website strtolower($website);
  175.         return $this;
  176.     }
  177.     /**
  178.      * Get website
  179.      *
  180.      * @return string
  181.      */
  182.     public function getWebsite()
  183.     {
  184.         return $this->website;
  185.     }
  186.     
  187.     /**
  188.      * Set phone
  189.      *
  190.      * @param string $phone
  191.      *
  192.      * @return Pro
  193.      */
  194.     public function setPhone($phone)
  195.     {
  196.         $this->phone $phone;
  197.         return $this;
  198.     }
  199.     /**
  200.      * Get phone
  201.      *
  202.      * @return string
  203.      */
  204.     public function getPhone()
  205.     {
  206.         return $this->phone;
  207.     }
  208.     
  209.     
  210.     /**
  211.      * Set description
  212.      *
  213.      * @param string $description
  214.      *
  215.      * @return Pro
  216.      */
  217.     public function setDescription($description)
  218.     {
  219.         $this->description $description;
  220.         return $this;
  221.     }
  222.     /**
  223.      * Get description
  224.      *
  225.      * @return string
  226.      */
  227.     public function getDescription()
  228.     {
  229.         return $this->description;
  230.     }
  231.     
  232.     
  233.     /**
  234.      * Set distributorGc
  235.      *
  236.      * @param boolean $distributorGc
  237.      *
  238.      * @return Pro
  239.      */
  240.     public function setDistributorGc($distributorGc)
  241.     {
  242.         $this->distributorGc $distributorGc;
  243.         return $this;
  244.     }
  245.     /**
  246.      * Get distributorGc
  247.      *
  248.      * @return boolean
  249.      */
  250.     public function getDistributorGc()
  251.     {
  252.         return $this->distributorGc;
  253.     }
  254.     
  255.     /**
  256.      * Set distributorCh
  257.      *
  258.      * @param boolean $distributorCh
  259.      *
  260.      * @return Pro
  261.      */
  262.     public function setDistributorCh($distributorCh)
  263.     {
  264.         $this->distributorCh $distributorCh;
  265.         return $this;
  266.     }
  267.     /**
  268.      * Get distributorCh
  269.      *
  270.      * @return boolean
  271.      */
  272.     public function getDistributorCh()
  273.     {
  274.         return $this->distributorCh;
  275.     }
  276.     
  277.     /**
  278.      * Set dateAskAccess
  279.      *
  280.      * @param \DateTime $dateAskAccess
  281.      *
  282.      * @return Pro
  283.      */
  284.     public function setDateAskAccess($dateAskAccess)
  285.     {
  286.         $this->dateAskAccess $dateAskAccess;
  287.         return $this;
  288.     }
  289.     /**
  290.      * Get dateAskAccess
  291.      *
  292.      * @return \DateTime
  293.      */
  294.     public function getDateAskAccess()
  295.     {
  296.         return $this->dateAskAccess;
  297.     }
  298.     
  299.     /**
  300.      * Set dateAskAccessGranted
  301.      *
  302.      * @param \DateTime $dateAskAccessGranted
  303.      *
  304.      * @return Pro
  305.      */
  306.     public function setDateAskAccessGranted($dateAskAccessGranted)
  307.     {
  308.         $this->dateAskAccessGranted $dateAskAccessGranted;
  309.         return $this;
  310.     }
  311.     /**
  312.      * Get dateAskAccessGranted
  313.      *
  314.      * @return \DateTime
  315.      */
  316.     public function getDateAskAccessGranted()
  317.     {
  318.         return $this->dateAskAccessGranted;
  319.     }
  320.     
  321.     /**
  322.      * Set dateSignin
  323.      *
  324.      * @param \DateTime $dateSignin
  325.      *
  326.      * @return Pro
  327.      */
  328.     public function setDateSignin($dateSignin)
  329.     {
  330.         $this->dateSignin $dateSignin;
  331.         return $this;
  332.     }
  333.     /**
  334.      * Get dateSignin
  335.      *
  336.      * @return \DateTime
  337.      */
  338.     public function getDateSignin()
  339.     {
  340.         return $this->dateSignin;
  341.     }
  342.     
  343.     /**
  344.      * Add openingHour
  345.      *
  346.      * @param \App\Entity\Pro\OpeningHour $openingHour
  347.      *
  348.      * @return Pro
  349.      */
  350.     public function addOpeningHour(\App\Entity\Pro\OpeningHour $openingHour)
  351.     {
  352.         $openingHour->setPro($this);
  353.         $this->openingHours[] = $openingHour;
  354.         return $this;
  355.     }
  356.     /**
  357.      * Remove openingHour
  358.      *
  359.      * @param \App\Entity\Pro\OpeningHour $openingHour
  360.      */
  361.     public function removeOpeningHour(\App\Entity\Pro\OpeningHour $openingHour)
  362.     {
  363.         $this->openingHours->removeElement($openingHour);
  364.     }
  365.     /**
  366.      * Get openingHours
  367.      *
  368.      * @return \Doctrine\Common\Collections\Collection
  369.      */
  370.     public function getOpeningHours()
  371.     {
  372.         return $this->openingHours;
  373.     }
  374.     
  375.     
  376.     /***********************
  377.      * OTHER FUNCTION
  378.      ***********************/
  379.     
  380.     public function getArrayForJson(){
  381.         $array = array();
  382.         $array['id'] = $this->getId();
  383.         if($this->getTypePro())
  384.             $array['proType'] = $this->getTypePro()->getArrayForJson();
  385.         $array['website'] = $this->getWebsite();
  386.         $array['phone'] = $this->getPhone();
  387.         $array['description'] = $this->getDescription();
  388.         
  389.         foreach($this->getOpeningHours() as $openingHour){
  390.             $array['openingHours'][] = $openingHour->getArrayForJson();
  391.         }
  392.         
  393.         
  394.         return $array;
  395.         
  396.     }
  397.     
  398. }