<?php
namespace App\Entity;
use App\Entity\Traits\PlatformIdTrait;
use App\Service\CurrencyConverter;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use DateTime;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
*/
class User implements UserInterface
{
use PlatformIdTrait;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
*/
private $activationCode;
/**
* @ORM\Column(type="string", length=255)
*/
private $verificationCode;
/**
* @ORM\Column(type="string", length=255)
*/
private $bookingCode;
/**
* @ORM\Column(type="string", length=180)
*/
private $hash = false;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="string", length=255)
*/
private $created_am;
/**
* @ORM\Column(type="string", length=255)
*/
private $verifycodeTime;
/**
* @ORM\Column(type="string", length=255)
*/
private $bookingcodeTime;
/**
* @ORM\Column(type="string", length=255)
*/
private $bookingValue = "";
/**
* @ORM\Column(type="string", length=255)
*/
private $codePromoName = "";
/**
* @ORM\Column(type="string", length=255)
*/
private $codePromoValue = "";
/**
* @ORM\Column(type="integer")
*/
private $codePromoStatus =0;
/**
* @ORM\Column(type="string", length=255)
*/
private $verificationDispo = "";
/**
* @ORM\Column(type="string", length=255)
*/
private $dispoTime = "";
/**
* @ORM\OneToMany(targetEntity="CustomerContact", mappedBy="user", cascade={"persist"})
*/
private $customercontact;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OrderBy({"createdAt" ="DESC"})
* @ORM\OneToMany(targetEntity="Invoice", mappedBy="user")
*/
private $invoices;
/**
* @ORM\Column(type="boolean", length=180)
*/
private $isActive = false;
/**
* @ORM\Column(type="string", length=50)
*/
private $foreName;
/**
* @ORM\OneToOne(targetEntity="Credit", mappedBy="user")
*/
private $credit;
/**
* @ORM\Column(type="integer", length=50, nullable=true)
*/
private $facebookId;
/**
* @ORM\Column(type="integer", length=50, nullable=true)
*/
private $countVerify;
/**
* @ORM\Column(type="integer", length=50, nullable=true)
*/
private $countBooking;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $houseNumber;
/**
* @ORM\Column(type="integer", length=50, nullable=true)
*/
private $zipCode;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $city;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $company;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $mobile;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $privatePhone;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $workPhone;
/**
* @ORM\Column(type="boolean")
*/
private $socialMedia = false;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $country;
/**
* @ORM\Column(type="string", length=50)
*/
private $currency = CurrencyConverter::currencyString['EUR'];
/**
* @return mixed
*/
public function getFacebookId()
{
return $this->facebookId;
}
/**
* @param mixed $facebookId
*/
public function setFacebookId($facebookId): void
{
$this->facebookId = $facebookId;
}
/**
* @return mixed
*/
public function getCountVerify()
{
return $this->countVerify;
}
/**
* @param mixed $countVerify
*/
public function setCountVerify($countVerify): void
{
$this->countVerify = $countVerify;
}
/**
* @return mixed
*/
public function getCountBooking()
{
return $this->countBooking;
}
/**
* @param mixed $countBooking
*/
public function setCountBooking($countBooking): void
{
$this->countBooking = $countBooking;
}
/**
* @return mixed
*/
public function getHash()
{
return $this->hash;
}
/**
* @param mixed $hash
*/
public function setHash($hash): void
{
$this->hash = $hash;
}
/**
* Gets triggered only on insert
* @ORM\PrePersist
*/
public function onPrePersist()
{
if (!$this->activationCode) {
$date = (new \DateTime('now'))->format('Y-m-d');
$email = $this->getEmail();
$this->setActivationCode(sha1($email . $date));
}
}
/**
* Set created_am
*
*/
public function setCreatedAm($createdAm): self
{
$this->created_am = $createdAm;
return $this;
}
/**
* Get created_am
*
*/
public function getCreatedAm()
{
return $this->created_am;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtToNow()
{
$this->setCreatedAm(new DateTime());
}
/**
* @return mixed
*/
public function getActivationCode()
{
return $this->activationCode;
}
/**
* @param mixed $activationCode
*/
public function setActivationCode($activationCode): void
{
$this->activationCode = $activationCode;
}
/**
* @return mixed
*/
public function getVerificationCode()
{
return $this->verificationCode;
}
/**
* @param mixed $verificationCode
*/
public function setVerificationCode($verificationCode): void
{
$this->verificationCode = $verificationCode;
}
/**
* @return mixed
*/
public function getBookingCode()
{
return $this->bookingCode;
}
/**
* @param mixed $bookingCode
*/
public function setBookingCode($bookingCode): void
{
$this->bookingCode = $bookingCode;
}
/**
* @return mixed
*/
public function getVerificationDispo()
{
return $this->verificationDispo;
}
/**
* @param mixed $verificationDispo
*/
public function setVerificationDispo($verificationDispo): void
{
$this->verificationDispo = $verificationDispo;
}
/**
* @return mixed
*/
public function getForeName()
{
return $this->foreName;
}
/**
* @param mixed $foreName
*/
public function setForeName($foreName): void
{
$this->foreName = $foreName;
}
/**
* @return mixed
*/
public function getAddress()
{
return $this->address;
}
/**
* @param mixed $address
*/
public function setAddress($address): void
{
$this->address = $address;
}
/**
* @return mixed
*/
public function getHouseNumber()
{
return $this->houseNumber;
}
/**
* @param mixed $houseNumber
*/
public function setHouseNumber($houseNumber): void
{
$this->houseNumber = $houseNumber;
}
/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}
/**
* @param mixed $company
*/
public function setCompany($company): void
{
$this->company = $company;
}
/**
* @return mixed
*/
public function getCurrency()
{
return $this->currency;
}
/**
* @param mixed $currency
*/
public function setCurrency($currency): void
{
$this->currency = $currency;
}
/**
* @return mixed
*/
public function getMobile()
{
return $this->mobile;
}
/**
* @param mixed $mobile
*/
public function setMobile($mobile): void
{
$this->mobile = $mobile;
}
/**
* @return mixed
*/
public function getPrivatePhone()
{
return $this->privatePhone;
}
/**
* @param mixed $privatePhone
*/
public function setPrivatePhone($privatePhone): void
{
$this->privatePhone = $privatePhone;
}
/**
* @return mixed
*/
public function getWorkPhone()
{
return $this->workPhone;
}
/**
* @param mixed $workPhone
*/
public function setWorkPhone($workPhone): void
{
$this->workPhone = $workPhone;
}
/**
* @return mixed
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* @param mixed $zipCode
*/
public function setZipCode($zipCode): void
{
$this->zipCode = $zipCode;
}
/**
* @return mixed
*/
public function getCity()
{
return $this->city;
}
/**
* @param mixed $city
*/
public function setCity($city): void
{
$this->city = $city;
}
/**
* @return mixed
*/
public function getSocialMedia()
{
return $this->socialMedia;
}
/**
* @param mixed $socialMedia
*/
public function setSocialMedia($socialMedia): void
{
$this->socialMedia = $socialMedia;
}
/**
* @return mixed
*/
public function getCountry()
{
return $this->country;
}
/**
* @param mixed $country
*/
public function setCountry($country): void
{
$this->country = $country;
}
public function getFullUserName()
{
return $this->getForeName();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @return mixed
*/
public function getInvoices()
{
return $this->invoices;
}
/**
* @param mixed $invoices
*/
public function setInvoices($invoices): void
{
$this->invoices = $invoices;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function setCustomerContact(CustomerContact $customercontact): self
{
$this->customercontact = $customercontact;
return $this;
}
public function getCustomerContact(): CustomerContact
{
return $this->customercontact;
}
/**
* @return Credit
*/
public function getCredit()
{
return $this->credit;
}
/**
* @param mixed $credit
*/
public function setCredit($credit): void
{
$this->credit = $credit;
}
/**
* @return mixed
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* @param mixed $isActive
*/
public function setIsActive($isActive): void
{
$this->isActive = $isActive;
}
/**
* @ORM\PrePersist
*/
public function setVerifycodeTimeToNow()
{
$this->setVerifycodeTime(new DateTime());
}
public function setVerifycodeTime($verifycodeTime): self
{
$this->verifycodeTime = $verifycodeTime;
return $this;
}
public function getVerifycodeTime()
{
return $this->verifycodeTime;
}
public function setBookingcodeTime($bookingcodeTime): self
{
$this->bookingcodeTime = $bookingcodeTime;
return $this;
}
public function getBookingcodeTime()
{
return $this->bookingcodeTime;
}
public function setDispoTime($dispoTime): self
{
$this->dispoTime = $dispoTime;
return $this;
}
public function getDispoTime()
{
return $this->dispoTime;
}
public function setCodePromoName($codePromoName): self
{
$this->codePromoName = $codePromoName;
return $this;
}
public function getCodePromoName()
{
return $this->codePromoName;
}
public function setCodePromoValue($codePromoValue): self
{
$this->codePromoValue = $codePromoValue;
return $this;
}
public function getCodePromoValue()
{
return $this->codePromoValue;
}
public function setBookingValue($bookingValue): self
{
$this->bookingValue = $bookingValue;
return $this;
}
public function getBookingValue()
{
return $this->bookingValue;
}
public function setCodePromoStatus($codePromoStatus): self
{
$this->codePromoStatus = $codePromoStatus;
return $this;
}
public function getCodePromoStatus()
{
return $this->codePromoStatus;
}
}