src/Entity/User.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\PlatformIdTrait;
  4. use App\Service\CurrencyConverter;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use DateTime;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  11.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  12.  */
  13. class User implements UserInterface
  14. {
  15.     use PlatformIdTrait;
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=180, unique=true)
  24.      */
  25.     private $email;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $activationCode;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $verificationCode;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private $bookingCode;
  38.     /**
  39.      * @ORM\Column(type="string", length=180)
  40.      */
  41.     private $hash false;
  42.     /**
  43.      * @ORM\Column(type="json")
  44.      */
  45.     private $roles = [];
  46.     /**
  47.      * @var string The hashed password
  48.      * @ORM\Column(type="string")
  49.      */
  50.     private $password;
  51.     /**
  52.      * @ORM\Column(type="string", length=255)
  53.      */
  54.     private $created_am;
  55.     /**
  56.      * @ORM\Column(type="string", length=255)
  57.      */
  58.     private $verifycodeTime;
  59.      /**
  60.      * @ORM\Column(type="string", length=255)
  61.      */
  62.     private $bookingcodeTime;
  63.      /**
  64.      * @ORM\Column(type="string", length=255)
  65.      */
  66.     private $bookingValue "";
  67.      /**
  68.      * @ORM\Column(type="string", length=255)
  69.      */
  70.     private $codePromoName "";
  71.      /**
  72.      * @ORM\Column(type="string", length=255)
  73.      */
  74.     private $codePromoValue "";
  75.      /**
  76.      * @ORM\Column(type="integer")
  77.      */
  78.     private $codePromoStatus =0;
  79.     /**
  80.      * @ORM\Column(type="string", length=255)
  81.      */
  82.     private $verificationDispo "";
  83.     /**
  84.       * @ORM\Column(type="string", length=255)
  85.      */
  86.     private $dispoTime "";
  87.     /**
  88.      * @ORM\OneToMany(targetEntity="CustomerContact", mappedBy="user", cascade={"persist"})
  89.      */
  90.     private $customercontact;
  91.     /**
  92.      * @ORM\Column(type="string", length=255)
  93.      */
  94.     private $name;
  95.     /**
  96.      * @ORM\OrderBy({"createdAt" ="DESC"})
  97.      * @ORM\OneToMany(targetEntity="Invoice", mappedBy="user")
  98.      */
  99.     private $invoices;
  100.     /**
  101.      * @ORM\Column(type="boolean", length=180)
  102.      */
  103.     private $isActive false;
  104.     /**
  105.      * @ORM\Column(type="string", length=50)
  106.      */
  107.     private $foreName;
  108.     /**
  109.      * @ORM\OneToOne(targetEntity="Credit", mappedBy="user")
  110.      */
  111.     private $credit;
  112.     /**
  113.      * @ORM\Column(type="integer", length=50, nullable=true)
  114.      */
  115.     private $facebookId;
  116.     /**
  117.      * @ORM\Column(type="integer", length=50, nullable=true)
  118.      */
  119.     private $countVerify;
  120.     
  121.     /**
  122.      * @ORM\Column(type="integer", length=50, nullable=true)
  123.      */
  124.     private $countBooking;
  125.     /**
  126.      * @ORM\Column(type="string", length=50, nullable=true)
  127.      */
  128.     private $address;
  129.     /**
  130.      * @ORM\Column(type="string", length=50, nullable=true)
  131.      */
  132.     private $houseNumber;
  133.     /**
  134.      * @ORM\Column(type="integer", length=50, nullable=true)
  135.      */
  136.     private $zipCode;
  137.     /**
  138.      * @ORM\Column(type="string", length=50, nullable=true)
  139.      */
  140.     private $city;
  141.     /**
  142.      * @ORM\Column(type="string", length=50, nullable=true)
  143.      */
  144.     private $company;
  145.     /**
  146.      * @ORM\Column(type="string", length=50, nullable=true)
  147.      */
  148.     private $mobile;
  149.     /**
  150.      * @ORM\Column(type="string", length=50, nullable=true)
  151.      */
  152.     private $privatePhone;
  153.     /**
  154.      * @ORM\Column(type="string", length=50, nullable=true)
  155.      */
  156.     private $workPhone;
  157.     /**
  158.      * @ORM\Column(type="boolean")
  159.      */
  160.     private $socialMedia false;
  161.   
  162.     /**
  163.      * @ORM\Column(type="string", nullable=true)
  164.      */
  165.     private $country;
  166.     /**
  167.      * @ORM\Column(type="string", length=50)
  168.      */
  169.     private $currency CurrencyConverter::currencyString['EUR'];
  170.     /**
  171.      * @return mixed
  172.      */
  173.     public function getFacebookId()
  174.     {
  175.         return $this->facebookId;
  176.     }
  177.     /**
  178.      * @param mixed $facebookId
  179.      */
  180.     public function setFacebookId($facebookId): void
  181.     {
  182.         $this->facebookId $facebookId;
  183.     }
  184.     /**
  185.      * @return mixed
  186.      */
  187.     public function getCountVerify()
  188.     {
  189.         return $this->countVerify;
  190.     }
  191.     /**
  192.      * @param mixed $countVerify
  193.      */
  194.     public function setCountVerify($countVerify): void
  195.     {
  196.         $this->countVerify $countVerify;
  197.     }
  198.     
  199.     /**
  200.      * @return mixed
  201.      */
  202.     public function getCountBooking()
  203.     {
  204.         return $this->countBooking;
  205.     }
  206.     /**
  207.      * @param mixed $countBooking
  208.      */
  209.     public function setCountBooking($countBooking): void
  210.     {
  211.         $this->countBooking $countBooking;
  212.     }
  213.     /**
  214.      * @return mixed
  215.      */
  216.     public function getHash()
  217.     {
  218.         return $this->hash;
  219.     }
  220.     /**
  221.      * @param mixed $hash
  222.      */
  223.     public function setHash($hash): void
  224.     {
  225.         $this->hash $hash;
  226.     }
  227.     /**
  228.      * Gets triggered only on insert
  229.      * @ORM\PrePersist
  230.      */
  231.     public function onPrePersist()
  232.     {
  233.         if (!$this->activationCode) {
  234.             $date = (new \DateTime('now'))->format('Y-m-d');
  235.             $email $this->getEmail();
  236.             $this->setActivationCode(sha1($email $date));
  237.         }
  238.     }
  239.      /**
  240.      * Set created_am
  241.      *
  242.      */
  243.     public function setCreatedAm($createdAm): self
  244.     {
  245.         $this->created_am $createdAm;
  246.         return $this;
  247.     }
  248.     /**
  249.      * Get created_am
  250.      *
  251.      */
  252.     public function getCreatedAm()
  253.     {
  254.         return $this->created_am;
  255.     }
  256.     /**
  257.      * @ORM\PrePersist
  258.      */
  259.     public function setCreatedAtToNow()
  260.     {
  261.        
  262.         $this->setCreatedAm(new DateTime());
  263.     }
  264.     /**
  265.      * @return mixed
  266.      */
  267.     public function getActivationCode()
  268.     {
  269.         return $this->activationCode;
  270.     }
  271.     /**
  272.      * @param mixed $activationCode
  273.      */
  274.     public function setActivationCode($activationCode): void
  275.     {
  276.         $this->activationCode $activationCode;
  277.     }
  278.     /**
  279.      * @return mixed
  280.      */
  281.     public function getVerificationCode()
  282.     {
  283.         return $this->verificationCode;
  284.     }
  285.     /**
  286.      * @param mixed $verificationCode
  287.      */
  288.     public function setVerificationCode($verificationCode): void
  289.     {
  290.         $this->verificationCode $verificationCode;
  291.     }
  292.      /**
  293.      * @return mixed
  294.      */
  295.     public function getBookingCode()
  296.     {
  297.         return $this->bookingCode;
  298.     }
  299.     /**
  300.      * @param mixed $bookingCode
  301.      */
  302.     public function setBookingCode($bookingCode): void
  303.     {
  304.         $this->bookingCode $bookingCode;
  305.     }
  306.      /**
  307.      * @return mixed
  308.      */
  309.     public function getVerificationDispo()
  310.     {
  311.         return $this->verificationDispo;
  312.     }
  313.     /**
  314.      * @param mixed $verificationDispo
  315.      */
  316.     public function setVerificationDispo($verificationDispo): void
  317.     {
  318.         $this->verificationDispo $verificationDispo;
  319.     }
  320.     /**
  321.      * @return mixed
  322.      */
  323.     public function getForeName()
  324.     {
  325.         return $this->foreName;
  326.     }
  327.     /**
  328.      * @param mixed $foreName
  329.      */
  330.     public function setForeName($foreName): void
  331.     {
  332.         $this->foreName $foreName;
  333.     }
  334.     /**
  335.      * @return mixed
  336.      */
  337.     public function getAddress()
  338.     {
  339.         return $this->address;
  340.     }
  341.     /**
  342.      * @param mixed $address
  343.      */
  344.     public function setAddress($address): void
  345.     {
  346.         $this->address $address;
  347.     }
  348.     /**
  349.      * @return mixed
  350.      */
  351.     public function getHouseNumber()
  352.     {
  353.         return $this->houseNumber;
  354.     }
  355.     /**
  356.      * @param mixed $houseNumber
  357.      */
  358.     public function setHouseNumber($houseNumber): void
  359.     {
  360.         $this->houseNumber $houseNumber;
  361.     }
  362.     /**
  363.      * @return mixed
  364.      */
  365.     public function getCompany()
  366.     {
  367.         return $this->company;
  368.     }
  369.     /**
  370.      * @param mixed $company
  371.      */
  372.     public function setCompany($company): void
  373.     {
  374.         $this->company $company;
  375.     }
  376.     /**
  377.      * @return mixed
  378.      */
  379.     public function getCurrency()
  380.     {
  381.         return $this->currency;
  382.     }
  383.     /**
  384.      * @param mixed $currency
  385.      */
  386.     public function setCurrency($currency): void
  387.     {
  388.         $this->currency $currency;
  389.     }
  390.     /**
  391.      * @return mixed
  392.      */
  393.     public function getMobile()
  394.     {
  395.         return $this->mobile;
  396.     }
  397.     /**
  398.      * @param mixed $mobile
  399.      */
  400.     public function setMobile($mobile): void
  401.     {
  402.         $this->mobile $mobile;
  403.     }
  404.     /**
  405.      * @return mixed
  406.      */
  407.     public function getPrivatePhone()
  408.     {
  409.         return $this->privatePhone;
  410.     }
  411.     /**
  412.      * @param mixed $privatePhone
  413.      */
  414.     public function setPrivatePhone($privatePhone): void
  415.     {
  416.         $this->privatePhone $privatePhone;
  417.     }
  418.     /**
  419.      * @return mixed
  420.      */
  421.     public function getWorkPhone()
  422.     {
  423.         return $this->workPhone;
  424.     }
  425.     /**
  426.      * @param mixed $workPhone
  427.      */
  428.     public function setWorkPhone($workPhone): void
  429.     {
  430.         $this->workPhone $workPhone;
  431.     }
  432.     /**
  433.      * @return mixed
  434.      */
  435.     public function getZipCode()
  436.     {
  437.         return $this->zipCode;
  438.     }
  439.     /**
  440.      * @param mixed $zipCode
  441.      */
  442.     public function setZipCode($zipCode): void
  443.     {
  444.         $this->zipCode $zipCode;
  445.     }
  446.     /**
  447.      * @return mixed
  448.      */
  449.     public function getCity()
  450.     {
  451.         return $this->city;
  452.     }
  453.     /**
  454.      * @param mixed $city
  455.      */
  456.     public function setCity($city): void
  457.     {
  458.         $this->city $city;
  459.     }
  460.     /**
  461.      * @return mixed
  462.      */
  463.     public function getSocialMedia()
  464.     {
  465.         return $this->socialMedia;
  466.     }
  467.     /**
  468.      * @param mixed $socialMedia
  469.      */
  470.     public function setSocialMedia($socialMedia): void
  471.     {
  472.         $this->socialMedia $socialMedia;
  473.     }
  474.   
  475.     /**
  476.      * @return mixed
  477.      */
  478.     public function getCountry()
  479.     {
  480.         return $this->country;
  481.     }
  482.     /**
  483.      * @param mixed $country
  484.      */
  485.     public function setCountry($country): void
  486.     {
  487.         $this->country $country;
  488.     }
  489.     public function getFullUserName()
  490.     {
  491.         return $this->getForeName();
  492.     }
  493.     public function getId(): ?int
  494.     {
  495.         return $this->id;
  496.     }
  497.     public function getEmail(): ?string
  498.     {
  499.         return $this->email;
  500.     }
  501.     public function setEmail(string $email): self
  502.     {
  503.         $this->email $email;
  504.         return $this;
  505.     }
  506.     /**
  507.      * A visual identifier that represents this user.
  508.      *
  509.      * @see UserInterface
  510.      */
  511.     public function getUsername(): string
  512.     {
  513.         return (string) $this->email;
  514.     }
  515.     /**
  516.      * @see UserInterface
  517.      */
  518.     public function getRoles(): array
  519.     {
  520.         $roles $this->roles;
  521.         // guarantee every user at least has ROLE_USER
  522.         $roles[] = 'ROLE_USER';
  523.         return array_unique($roles);
  524.     }
  525.     public function setRoles(array $roles): self
  526.     {
  527.         $this->roles $roles;
  528.         return $this;
  529.     }
  530.     /**
  531.      * @return mixed
  532.      */
  533.     public function getInvoices()
  534.     {
  535.         return $this->invoices;
  536.     }
  537.     /**
  538.      * @param mixed $invoices
  539.      */
  540.     public function setInvoices($invoices): void
  541.     {
  542.         $this->invoices $invoices;
  543.     }
  544.     /**
  545.      * @see UserInterface
  546.      */
  547.     public function getPassword(): string
  548.     {
  549.         return (string) $this->password;
  550.     }
  551.     public function setPassword(string $password): self
  552.     {
  553.         $this->password $password;
  554.         return $this;
  555.     }
  556.     /**
  557.      * @see UserInterface
  558.      */
  559.     public function getSalt()
  560.     {
  561.         // not needed when using the "bcrypt" algorithm in security.yaml
  562.     }
  563.     /**
  564.      * @see UserInterface
  565.      */
  566.     public function eraseCredentials()
  567.     {
  568.         // If you store any temporary, sensitive data on the user, clear it here
  569.         // $this->plainPassword = null;
  570.     }
  571.     public function getName(): ?string
  572.     {
  573.         return $this->name;
  574.     }
  575.     public function setName(string $name): self
  576.     {
  577.         $this->name $name;
  578.         return $this;
  579.     }
  580.     public function setCustomerContact(CustomerContact $customercontact): self
  581.     {
  582.         $this->customercontact $customercontact;
  583.         return $this;
  584.     }
  585.     public function getCustomerContact(): CustomerContact
  586.     {
  587.         return $this->customercontact;
  588.     }
  589.     /**
  590.      * @return Credit
  591.      */
  592.     public function getCredit()
  593.     {
  594.         return $this->credit;
  595.     }
  596.     /**
  597.      * @param mixed $credit
  598.      */
  599.     public function setCredit($credit): void
  600.     {
  601.         $this->credit $credit;
  602.     }
  603.      /**
  604.      * @return mixed
  605.      */
  606.     public function getIsActive()
  607.     {
  608.         return $this->isActive;
  609.     }
  610.     /**
  611.      * @param mixed $isActive
  612.      */
  613.     public function setIsActive($isActive): void
  614.     {
  615.         $this->isActive $isActive;
  616.     }
  617.      /**
  618.      * @ORM\PrePersist
  619.      */
  620.     public function setVerifycodeTimeToNow()
  621.     {
  622.        
  623.         $this->setVerifycodeTime(new DateTime());
  624.     }
  625.     
  626.     public function setVerifycodeTime($verifycodeTime): self
  627.     {
  628.         $this->verifycodeTime $verifycodeTime;
  629.         return $this;
  630.     }
  631.     public function getVerifycodeTime()
  632.     {
  633.         return $this->verifycodeTime;
  634.     }
  635.      
  636.     public function setBookingcodeTime($bookingcodeTime): self
  637.     {
  638.         $this->bookingcodeTime $bookingcodeTime;
  639.         return $this;
  640.     }
  641.     public function getBookingcodeTime()
  642.     {
  643.         return $this->bookingcodeTime;
  644.     }
  645.   
  646.     public function setDispoTime($dispoTime): self
  647.     {
  648.         $this->dispoTime $dispoTime;
  649.         return $this;
  650.     }
  651.     public function getDispoTime()
  652.     {
  653.         return $this->dispoTime;
  654.     }
  655.     public function setCodePromoName($codePromoName): self
  656.     {
  657.         $this->codePromoName $codePromoName;
  658.         return $this;
  659.     }
  660.     public function getCodePromoName()
  661.     {
  662.         return $this->codePromoName;
  663.     }
  664.     
  665.     public function setCodePromoValue($codePromoValue): self
  666.     {
  667.         $this->codePromoValue $codePromoValue;
  668.         return $this;
  669.     }
  670.     public function getCodePromoValue()
  671.     {
  672.         return $this->codePromoValue;
  673.     }
  674.     public function setBookingValue($bookingValue): self
  675.     {
  676.         $this->bookingValue $bookingValue;
  677.         return $this;
  678.     }
  679.     public function getBookingValue()
  680.     {
  681.         return $this->bookingValue;
  682.     }
  683.     
  684.     public function setCodePromoStatus($codePromoStatus): self
  685.     {
  686.         $this->codePromoStatus $codePromoStatus;
  687.         return $this;
  688.     }
  689.     public function getCodePromoStatus()
  690.     {
  691.         return $this->codePromoStatus;
  692.     }
  693. }