<?php
namespace App\Entity;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Users
*
* @ORM\Table(name="users", indexes={@ORM\Index(name="users_companies_fk", columns={"company_id"}), @ORM\Index(name="users_category_fk", columns={"category_id"}), @ORM\Index(name="users_created_fk", columns={"created_by"})})
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*
* @UniqueEntity(fields="mobileNumber", message="mobile number already taken")
* @UniqueEntity(fields="username", message="identification number is already exist")
* @ORM\Entity(repositoryClass="App\Entity\UsersRepository")
*/
class Users implements UserInterface, \Serializable
{
/**
* @var string
*
* @ORM\Column(name="user_id", type="guid", length=36, nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="UUID")
*/
private $userId;
/**
* @var string
*
*
* @ORM\Column(name="username", type="string", length=50, nullable=true)
*/
private $username;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=64, nullable=true)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="telephone", type="string", length=20, nullable=true)
*/
private $telephone;
/**
* @var array
*
* @ORM\Column(name="roles", type="array")
*/
private $roles = array('ROLE_USER');
/**
* @var string
*
* @ORM\Column(name="mobile_number", type="string", length=20, nullable=true)
*/
private $mobileNumber;
/**
* @var string
*
* @ORM\Column(name="mobile_number2", type="string", length=20, nullable=true)
*/
private $mobileNumber2;
/**
* @var boolean
*
* @ORM\Column(name="is_mobile_number2_verified", type="boolean", nullable=false)
*
*/
private $isMobileNumber2Verified = 0 ;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=50, nullable=true)
*/
private $email;
/**
* @var boolean
*
* @ORM\Column(name="email_verified", type="boolean", nullable=false)
*/
private $emailVerified = 0;
/**
* @var string
*
* @ORM\Column(name="verify_token", type="string", length=100, nullable=true)
*/
private $verify_token;
/**
* @var float
*
* @ORM\Column(name="balance", type="float", precision=10, scale=0, nullable=true)
*/
private $balance;
/**
* @var float
*
* @ORM\Column(name="locked_ot_security", type="float", precision=10, scale=0, nullable=true)
*/
private $lockedOtSecurity;
/**
* @var boolean
*
* @ORM\Column(name="is_verified", type="boolean", nullable=false)
*/
private $isVerified = 0;
/**
* @var boolean
*
* @ORM\Column(name="is_deleted", type="boolean", nullable=false)
*/
private $isDeleted = 0;
/**
* @var boolean
*
* @ORM\Column(name="is_receive_sms", type="boolean", nullable=false)
*/
private $isReceiveSms = false;
/**
* @var \DateTime
*
* @ORM\Column(name="last_login", type="datetime", nullable=true)
*/
private $lastLogin;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @var UsersCategories
*
* @ORM\ManyToOne(targetEntity="UsersCategories")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="category_id", referencedColumnName="category_id")
* })
*/
private $category;
/**
* @var Companies
*
* @ORM\ManyToOne(targetEntity="Companies")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="company_id", referencedColumnName="company_id")
* })
*/
private $company;
/**
* @var Users
*
* @ORM\ManyToOne(targetEntity="Users")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="created_by", referencedColumnName="user_id")
* })
*/
private $createdBy;
/**
* @var Users
*
* @ORM\ManyToOne(targetEntity="Users")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="updated_by", referencedColumnName="user_id")
* })
*/
private $updatedBy;
/**
* @var UserIdentityInfo
*
* @ORM\OneToOne(targetEntity="UserIdentityInfo", mappedBy="user", cascade={"persist"})
*@Assert\Valid
*/
private $userIdentityInfo;
/**
* @var UserAdditionalDetails
*
* @ORM\OneToOne(targetEntity="UserAdditionalDetails", mappedBy="user", cascade={"persist"})
*/
private $userAdditionalDetails;
/**
* @ORM\OneToMany(targetEntity="App\Entity\UserBankDetails", mappedBy="user")
*/
private $bankAccounts;
/**
* @var string
*
* @ORM\Column(name="profile_origin", type="string", nullable=true, columnDefinition="enum('self registered','created','imported')")
*/
private $profileOrigin;
/**
* @var string
*
* @ORM\Column(name="signature_path", type="string", length=100, nullable=true)
*/
private $signaturePath;
/**
* @var string
*
*/
private $signatureWebPath;
/**
* Get id
*
* @return string
*/
public function getId()
{
return $this->getUserId();
}
/**
* Set userId
*
* @param string $userId
*
* @return Users
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId
*
* @return string
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set username
*
* @param string $username
*
* @return Users
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Set password
*
* @param string $password
*
* @return Users
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Set telephone
*
* @param string $telephone
*
* @return Users
*/
public function setTelephone($telephone)
{
$this->telephone = $telephone;
return $this;
}
/**
* Get telephone
*
* @return string
*/
public function getTelephone()
{
return $this->telephone;
}
/**
* Set mobileNumber
*
* @param string $mobileNumber
*
* @return Users
*/
public function setMobileNumber($mobileNumber)
{
$this->mobileNumber = $mobileNumber;
return $this;
}
/**
* Get mobileNumber
*
* @return string
*/
public function getMobileNumber()
{
return $this->mobileNumber;
}
/**
* Set mobileNumber2
*
* @param string $mobileNumber2
*
* @return Users
*/
public function setMobileNumber2($mobileNumber2)
{
$this->mobileNumber2 = $mobileNumber2;
return $this;
}
/**
* Get mobileNumber2
*
* @return string
*/
public function getMobileNumber2()
{
return $this->mobileNumber2;
}
/**
* @return bool
*/
public function getIsMobileNumber2Verified()
{
return $this->isMobileNumber2Verified;
}
/**
* @param bool $isMobileNumber2Verified
*/
public function setIsMobileNumber2Verified($isMobileNumber2Verified)
{
$this->isMobileNumber2Verified = $isMobileNumber2Verified;
}
/**
* Set email
*
* @param string $email
*
* @return Users
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set emailVerified
*
* @param boolean $emailVerified
*
* @return Users
*/
public function setEmailVerified($emailVerified)
{
$this->emailVerified = $emailVerified;
return $this;
}
/**
* Get emailVerified
*
* @return boolean
*/
public function getEmailVerified()
{
return $this->emailVerified;
}
/**
* Set verify_token
*
* @param string $verify_token
*
* @return Users
*/
public function setVerifyToken($verify_token)
{
$this->verify_token = $verify_token;
return $this;
}
/**
* Get verify_token
*
* @return string
*/
public function getVerifyToken()
{
return $this->verify_token;
}
/**
* Set balance
*
* @param float $balance
*
* @return Users
*/
public function setBalance($balance)
{
$this->balance = $balance;
return $this;
}
/**
* Get balance
*
* @return float
*/
public function getBalance()
{
return $this->balance;
}
/**
* Set lockedOtSecurity
*
* @param float $lockedOtSecurity
*
* @return Users
*/
public function setLockedOtSecurity($lockedOtSecurity)
{
$this->lockedOtSecurity = $lockedOtSecurity;
return $this;
}
/**
* Get lockedOtSecurity
*
* @return float
*/
public function getLockedOtSecurity()
{
return $this->lockedOtSecurity;
}
/**
* Set isVerified
*
* @param boolean $isVerified
*
* @return Users
*/
public function setIsVerified($isVerified)
{
$this->isVerified = $isVerified;
return $this;
}
/**
* Get isVerified
*
* @return boolean
*/
public function getIsVerified()
{
return $this->isVerified;
}
/**
* Set isDeleted
*
* @param boolean $isDeleted
*
* @return Users
*/
public function setIsDeleted($isDeleted)
{
$this->isDeleted = $isDeleted;
return $this;
}
/**
* Get isDeleted
*
* @return boolean
*/
public function getIsDeleted()
{
return $this->isDeleted;
}
/**
* Set isReceiveSms
*
* @param boolean $isReceiveSms
*
* @return Users
*/
public function setIsReceiveSms($isReceiveSms)
{
$this->isReceiveSms = $isReceiveSms;
return $this;
}
/**
* Get isReceiveSms
*
* @return boolean
*/
public function getIsReceiveSms()
{
return $this->isReceiveSms;
}
/**
* Set lastLogin
*
* @param \DateTime $lastLogin
*
* @return Users
*/
public function setLastLogin($lastLogin)
{
$this->lastLogin = $lastLogin;
return $this;
}
/**
* Get lastLogin
*
* @return \DateTime
*/
public function getLastLogin()
{
return $this->lastLogin;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Users
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return Users
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set category
*
* @param UsersCategories $category
*
* @return Users
*/
public function setCategory(UsersCategories $category = null)
{
$this->category = $category;
return $this;
}
/**
* Get category
*
* @return UsersCategories
*/
public function getCategory()
{
return $this->category;
}
/**
* Set company
*
* @param Companies $company
*
* @return Users
*/
public function setCompany(Companies $company = null)
{
$this->company = $company;
return $this;
}
/**
* Get company
*
* @return Companies
*/
public function getCompany()
{
return $this->company;
}
/**
* Set createdBy
*
* @param Users $createdBy
*
* @return Users
*/
public function setCreatedBy(Users $createdBy = null)
{
$this->createdBy = $createdBy;
return $this;
}
/**
* Get createdBy
*
* @return Users
*/
public function getCreatedBy()
{
return $this->createdBy;
}
/**
* @return string
*/
public function getProfileOrigin()
{
return $this->profileOrigin;
}
/**
* @param string $profileOrigin
*/
public function setProfileOrigin($profileOrigin)
{
$this->profileOrigin = $profileOrigin;
}
/**
* Set updatedBy
*
* @param Users $updatedBy
*
* @return Users
*/
public function setUpdatedBy(Users $updatedBy = null)
{
$this->updatedBy = $updatedBy;
return $this;
}
/**
* Get updatedBy
*
* @return Users
*/
public function getUpdatedBy()
{
return $this->updatedBy;
}
/**
* Set userIdentityInfo
*
* @param UserIdentityInfo $userIdentityInfo
*
* @return Users
*/
public function setUserIdentityInfo(UserIdentityInfo $userIdentityInfo = null)
{
$this->userIdentityInfo = $userIdentityInfo;
return $this;
}
/**
* Get userIdentityInfo
*
* @return UserIdentityInfo
*/
public function getUserIdentityInfo()
{
return $this->userIdentityInfo;
}
/**
* Set userAdditionalDetails
*
* @param UserAdditionalDetails $userAdditionalDetails
*
* @return Users
*/
public function setUserAdditionalDetails(UserAdditionalDetails $userAdditionalDetails = null)
{
$this->userAdditionalDetails = $userAdditionalDetails;
return $this;
}
/**
* Get userAdditionalDetails
*
* @return UserAdditionalDetails
*/
public function getUserAdditionalDetails()
{
return $this->userAdditionalDetails;
}
/**
* @ORM\PrePersist
*/
public function prePersist() {
if ($this->getCreatedAt() == null) {
$this->setCreatedAt(new \DateTime(date('Y-m-d H:i:s')));
}
}
/**
* @ORM\PreUpdate
*
* @param PreUpdateEventArgs $event
*/
public function preUpdate(PreUpdateEventArgs $event) {
if (!$event->hasChangedField('last_login')) {
$this->setUpdatedAt(new \DateTime(date('Y-m-d H:i:s')));
}
}
/**
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* @return null|string
*/
public function getSalt()
{
// you *may* need a real salt depending on your encoder
// see section on salt below
return null;
}
/**
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* @return array
*/
public function getRoles()
{
return $this->roles != null ? $this->roles : array('ROLE_USER');
}
/**
*
*/
public function eraseCredentials()
{}
/**
* @see \Serializable::serialize()
*
* @return string
*/
public function serialize()
{
return serialize(array(
$this->userId,
$this->username,
$this->password,
// see section on salt below
// $this->salt,
));
}
/**
* @see \Serializable::unserialize()
*
* @param string $serialized
*/
public function unserialize($serialized)
{
list (
$this->userId,
$this->username,
$this->password,
// see section on salt below
// $this->salt
) = unserialize($serialized);
}
/**
* Set roles
*
* @param array $roles
*
* @return Users
*/
public function setRoles($roles)
{
$this->roles = $roles;
return $this;
}
/**
* Get the entity class name
*
* @return string
* @throws \ReflectionException
*/
public function getEntityName() {
return (new \ReflectionClass($this))->getShortName();
}
/**
* @return mixed
*/
public function getUserBankDetails(){
return $this->bankAccounts;
}
/**
* @return string
*/
public function getSignaturePath()
{
return $this->signaturePath;
}
/**
* @param string $signaturePath
*/
public function setSignaturePath($signaturePath)
{
$this->signaturePath = $signaturePath;
}
/**
* @return string
*/
public function getSignatureWebPath()
{
return $this->signatureWebPath;
}
/**
* @param string $signatureWebPath
*/
public function setSignatureWebPath($signatureWebPath)
{
$this->signatureWebPath = $signatureWebPath;
}
/**
* This is to enable fetching user name via VehicleClient->getActualClient() without knowing if it was company or user
*
* @param string $locale
*
* @return string
*/
public function getName($locale= 'ar')
{
if($locale == 'en'){
return $this->getUserIdentityInfo()->getFullNameEn(1);
}else{
return $this->getUserIdentityInfo()->getFullNameAr(1);
}
}
}