<?php
namespace EADPlataforma\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use EADPlataforma\Validator\Constraints as EADAssert;
use EADPlataforma\Services\FileService;
use EADPlataforma\Util\StringUtil;
use EADPlataforma\Enum\UserEnum;
use \DateTime;
/**
* User
*
* @ORM\Table(name="user", indexes={
* @ORM\Index(name="fk_user_country_id", columns={"country_id"}),
* @ORM\Index(name="fk_user_state_id", columns={"state_id"}),
* @ORM\Index(name="fk_user_city_id", columns={"city_id"}),
* @ORM\Index(name="fk_user_user_profile_id", columns={"user_profile_id"}),
* @ORM\Index(name="fk_user_user_delete_id", columns={"user_delete_id"})
* })
*
* @ORM\Entity(repositoryClass="EADPlataforma\Repository\UserRepository")
*
*/
class User implements UserInterface
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @Assert\NotBlank(
* message = "Deleted not informed"
* )
*
* @Assert\Choice(
* choices = {
* UserEnum::ITEM_NO_DELETED,
* UserEnum::ITEM_ON_TRASH,
* UserEnum::ITEM_DELETED
* },
* message = "Delete Option Invalid"
* )
*
* @var int
*
* @ORM\Column(name="deleted", type="integer", nullable=false, options={"default"="0"})
*/
private $deleted = UserEnum::ITEM_NO_DELETED;
/**
* @Assert\NotBlank(
* message = "Hash not informed"
* )
*
* @var string
*
* @ORM\Column(name="hash_identify", type="string", length=80, nullable=true)
*/
private $hashIdentify;
/**
* @Assert\NotBlank(
* message = "Name not informed"
* )
*
* @Assert\Length(
* min = 0,
* max = 75
* )
*
* @var string
*
* @ORM\Column(name="name", type="string", length=80, nullable=false)
*/
private $name;
/**
* @Assert\NotBlank(
* message = "Email not informed"
* )
*
* @Assert\Email(
* message = "Email Invalid"
* )
*
* @Assert\Length(
* min = 0,
* max = 75
* )
*
* @var string
*
* @ORM\Column(name="email", type="string", length=80, nullable=false)
*/
private $email;
/**
* @Assert\NotBlank(
* message = "Password not informed"
* )
*
* @Assert\Length(
* min = 6,
* max = 40
* )
*
* @var string
*
* @ORM\Column(name="password", type="string", length=45, nullable=false)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="old_password", type="text", nullable=true)
*/
private $oldPassword;
/**
* @Assert\NotBlank(
* message = "Username not informed"
* )
*
* @Assert\Length(
* min = 0,
* max = 250
* )
*
* @var string
*
* @ORM\Column(name="username", type="string", length=255, nullable=false)
*/
private $username;
/**
* @Assert\NotBlank(
* message = "Type not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::STUDENT, UserEnum::TUTOR, UserEnum::TEACHER, UserEnum::ADMIN },
* message = "Type Invalid"
* )
*
* @var int
*
* @ORM\Column(name="type", type="integer", nullable=false, options={"default"="1"})
*/
private $type = UserEnum::STUDENT;
/**
* @Assert\NotBlank(
* message = "Old Status not informed"
* )
*
* @Assert\Choice(
* choices = {
* UserEnum::WAITING,
* UserEnum::ACTIVE,
* UserEnum::BLOCK,
* UserEnum::INACTIVE
* },
* message = "Old Status Invalid"
* )
*
* @var int
*
* @ORM\Column(name="old_status", type="integer", nullable=false, options={"default"="0"})
*/
private $oldStatus = UserEnum::WAITING;
/**
* @Assert\NotBlank(
* message = "Status not informed"
* )
*
* @Assert\Choice(
* choices = {
* UserEnum::WAITING,
* UserEnum::ACTIVE,
* UserEnum::BLOCK,
* UserEnum::INACTIVE
* },
* message = "Status Invalid"
* )
*
* @var int
*
* @ORM\Column(name="status", type="integer", nullable=false, options={"default"="0"})
*/
private $status = UserEnum::WAITING;
/**
* @Assert\NotBlank(
* message = "Valid Email not informed"
* )
*
* @Assert\Choice(
* choices = {
* UserEnum::UNKNOWN,
* UserEnum::DELIVERABLE,
* UserEnum::UNDELIVERABLE,
* UserEnum::REFUSE
* },
* message = "Delete Option Invalid"
* )
*
* @var int
*
* @ORM\Column(name="valid_email", type="integer", nullable=false, options={"default"="0"})
*/
private $validEmail = UserEnum::UNKNOWN;
/**
* @Assert\NotBlank(
* message = "Complete not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Complete Invalid"
* )
*
* @var int
*
* @ORM\Column(name="complete", type="integer", nullable=false, options={"default"="0"})
*/
private $complete = UserEnum::NO;
/**
* @Assert\NotBlank(
* message = "Spotlight not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Spotlight Invalid"
* )
*
* @var int
*
* @ORM\Column(name="teacher_spotlight", type="integer", nullable=false, options={"default"="0"})
*/
private $teacherSpotlight = UserEnum::NO;
/**
* @Assert\NotBlank(
* message = "Permission not informed"
* )
*
* @Assert\Json(
* message = "Permission is an invalid Json."
* )
*
* @var string
*
* @ORM\Column(name="permission", type="text", nullable=false)
*/
private $permission;
/**
* @Assert\NotBlank(
* message = "Date Register not informed"
* )
*
* @EADAssert\DateTimeEAD(
* message = "Date Register Invalid"
* )
*
* @var \DateTime
*
* @ORM\Column(name="date_register", type="datetime", nullable=false, options={"default"="CURRENT_TIMESTAMP"})
*/
private $dateRegister;
/**
* @EADAssert\DateTimeEAD(
* message = "Date Last Access Invalid"
* )
*
* @var \DateTime
*
* @ORM\Column(name="date_last_access", type="datetime", nullable=true, options={"default"="CURRENT_TIMESTAMP"})
*/
private $dateLastAccess;
/**
* @var string
*
* @ORM\Column(name="authentication_secret_key", type="string", length=80, nullable=true)
*/
private $authenticationSecretKey;
/**
* @var string
*
* @ORM\Column(name="authentication_code_email", type="string", length=10, nullable=true)
*/
private $authenticationCodeEmail;
/**
* @EADAssert\DateTimeEAD(
* message = "Authentication Email Date Expire Invalid"
* )
*
* @var \DateTime
*
* @ORM\Column(name="authentication_email_date_expire", type="datetime", nullable=true)
*/
private $authenticationEmailDateExpire;
/**
* @Assert\NotBlank(
* message = "Authentication Allow not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Authentication Invalid"
* )
*
* @var int
*
* @ORM\Column(name="authentication_allow", type="integer", nullable=false, options={"default"="0"})
*/
private $authenticationAllow = UserEnum::NO;
/**
* @Assert\NotBlank(
* message = "Allow Receiver not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Receiver Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_receiver", type="integer", nullable=false, options={"default"="0"})
*/
private $allowReceiver = UserEnum::NO;
/**
* @Assert\NotBlank(
* message = "Allow Onde Click Buy not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Onde Click Buy Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_one_click_buy", type="integer", nullable=false, options={"default"="1"})
*/
private $allowOneClickBuy = UserEnum::YES;
/**
* @Assert\NotBlank(
* message = "Allow Notify New Lesson not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Notify New Lesson Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_notify_new_lesson", type="integer", nullable=false, options={"default"="1"})
*/
private $allowNotifyNewLesson = UserEnum::YES;
/**
* @Assert\NotBlank(
* message = "Allow Notify New Exam not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Notify New Exam Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_notify_new_exam", type="integer", nullable=false, options={"default"="1"})
*/
private $allowNotifyNewExam = UserEnum::YES;
/**
* @Assert\NotBlank(
* message = "Allow Notify New Support Message not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Notify New Support Message Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_notify_new_support_message", type="integer", nullable=false, options={"default"="1"})
*/
private $allowNotifyNewSupportMessage = UserEnum::YES;
/**
* @Assert\NotBlank(
* message = "Allow Notify New Support Answer not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Notify New Support Answer Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_notify_new_support_answer", type="integer", nullable=false, options={"default"="1"})
*/
private $allowNotifyNewSupportAnswer = UserEnum::YES;
/**
* @Assert\NotBlank(
* message = "Allow Notify New Message not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Notify New Message Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_notify_new_message", type="integer", nullable=false, options={"default"="1"})
*/
private $allowNotifyNewMessage = UserEnum::YES;
/**
* @Assert\NotBlank(
* message = "Allow Notify New Group Message not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Notify New Group Message Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_notify_new_group_message", type="integer", nullable=false, options={"default"="1"})
*/
private $allowNotifyNewGroupMessage = UserEnum::YES;
/**
* @Assert\NotBlank(
* message = "Allow Notify Cart not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Allow Notify Cart Invalid"
* )
*
* @var int
*
* @ORM\Column(name="allow_notify_cart", type="integer", nullable=false, options={"default"="1"})
*/
private $allowNotifyCart = UserEnum::YES;
/**
* @Assert\Length(
* min = 0,
* max = 40
* )
*
* @var string|null
*
* @ORM\Column(name="document", type="string", length=45, nullable=true)
*/
private $document;
/**
* @Assert\Length(
* min = 0,
* max = 250
* )
*
* @var string|null
*
* @ORM\Column(name="photo", type="string", length=255, nullable=true)
*/
private $photo;
/**
* @Assert\Length(
* min = 0,
* max = 230
* )
*
* @var string|null
*
* @ORM\Column(name="cover", type="string", length=235, nullable=true)
*/
private $cover;
/**
* @Assert\Length(
* min = 0,
* max = 45
* )
*
* @var string|null
*
* @ORM\Column(name="occupation", type="string", length=50, nullable=true)
*/
private $occupation;
/**
* @Assert\Length(
* min = 0,
* max = 175
* )
*
* @var string|null
*
* @ORM\Column(name="biography", type="string", length=180, nullable=true)
*/
private $biography;
/**
* @var string|null
*
* @ORM\Column(name="resume", type="text", length=0, nullable=true)
*/
private $resume;
/**
* @var string|null
*
* @ORM\Column(name="custom", type="text", length=0, nullable=true)
*/
private $custom;
/**
* @var string|null
*
* @ORM\Column(name="notes", type="text", length=0, nullable=true)
*/
private $notes;
/**
* @EADAssert\DateEAD(
* message = "Birth Date Invalid"
* )
*
* @var Date|null
*
* @ORM\Column(name="birth_date", type="date", nullable=true)
*/
private $birthDate;
/**
* @Assert\Length(
* min = 0,
* max = 40
* )
*
* @var string|null
*
* @ORM\Column(name="phone", type="string", length=45, nullable=true)
*/
private $phone;
/**
* @Assert\Length(
* min = 0,
* max = 40
* )
*
* @var string|null
*
* @ORM\Column(name="zip_code", type="string", length=45, nullable=true)
*/
private $zipCode;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="address", type="string", length=120, nullable=true)
*/
private $address;
/**
* @Assert\Length(
* min = 0,
* max = 10
* )
*
* @var string|null
*
* @ORM\Column(name="address_number", type="string", length=15, nullable=true)
*/
private $addressNumber;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="address_complement", type="string", length=120, nullable=true)
*/
private $addressComplement;
/**
* @Assert\Length(
* min = 0,
* max = 60
* )
*
* @var string|null
*
* @ORM\Column(name="address_neighborhood", type="string", length=65, nullable=true)
*/
private $addressNeighborhood;
/**
* @Assert\Json(
* message = "Custom Field is an invalid Json."
* )
*
* @var string
*
* @ORM\Column(name="custom_field", type="text", nullable=true)
*/
private $customField;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="website", type="string", length=120, nullable=true)
*/
private $website;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="twitter", type="string", length=120, nullable=true)
*/
private $twitter;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="facebook", type="string", length=120, nullable=true)
*/
private $facebook;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="linkedin", type="string", length=120, nullable=true)
*/
private $linkedin;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="youtube", type="string", length=120, nullable=true)
*/
private $youtube;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="instagram", type="string", length=120, nullable=true)
*/
private $instagram;
/**
* @Assert\Length(
* min = 0,
* max = 115
* )
*
* @var string|null
*
* @ORM\Column(name="tiktok", type="string", length=120, nullable=true)
*/
private $tiktok;
/**
* @Assert\NotBlank(
* message = "Invited not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Invited Invalid"
* )
*
* @var int
*
* @ORM\Column(name="invited", type="integer", nullable=false, options={"default"="0"})
*/
private $invited = UserEnum::NO;
/**
* @EADAssert\DatetimeEAD(
* message = "Confirmation Date Invalid"
* )
*
* @var \Date
*
* @ORM\Column(name="confirmation_date", type="datetime", nullable=true)
*/
private $confirmationDate;
/**
* @EADAssert\DateEAD(
* message = "Recover Date Invalid"
* )
*
* @var \Date
*
* @ORM\Column(name="recover_date", type="date", nullable=true)
*/
private $recoverDate;
/**
* @var int
*
* @ORM\Column(name="recover_attempt", type="integer", nullable=false, options={"default"="0"})
*/
private $recoverAttempt = "0";
/**
* @Assert\NotBlank(
* message = "Screen Size not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::SCREEN_SMALL, UserEnum::SCREEN_MEDIUM, UserEnum::SCREEN_LARGE },
* message = "Screen Size"
* )
*
* @var int
*
* @ORM\Column(name="screen_size", type="integer", nullable=false, options={"default"="2"})
*/
private $screenSize = UserEnum::SCREEN_MEDIUM;
/**
* @Assert\NotBlank(
* message = "Autoplay not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Autoplay Invalid"
* )
*
* @var int
*
* @ORM\Column(name="autoplay", type="integer", nullable=false, options={"default"="0"})
*/
private $autoplay = UserEnum::NO;
/**
* @Assert\NotBlank(
* message = "Accept Terms not informed"
* )
*
* @Assert\Choice(
* choices = { UserEnum::NO, UserEnum::YES },
* message = "Accept Terms Invalid"
* )
*
* @var int
*
* @ORM\Column(name="accept_terms", type="integer", nullable=false, options={"default"="0"})
*/
private $acceptTerms = UserEnum::NO;
/**
* @var string|null
*
* @ORM\Column(name="accept_terms_contract", type="text", length=0, nullable=true)
*/
private $acceptTermsContract;
/**
* @EADAssert\DateTimeEAD(
* message = "Accept Terms Date Invalid"
* )
*
* @var \DateTime|null
*
* @ORM\Column(name="accept_terms_date", type="datetime", nullable=true)
*/
private $acceptTermsDate;
/**
* @var int
*
* @ORM\Column(name="pipedrive_person_id", type="integer", nullable=true)
*/
private $pipedrivePerson;
/**
* @Assert\Valid
*
* @var \City
*
* @ORM\ManyToOne(targetEntity="City")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="city_id", referencedColumnName="id", nullable=true)
* })
*/
private $city;
/**
* @Assert\Valid
*
* @var \State
*
* @ORM\ManyToOne(targetEntity="State")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="state_id", referencedColumnName="id", nullable=true)
* })
*/
private $state;
/**
* @Assert\Valid
*
* @var \Country
*
* @ORM\ManyToOne(targetEntity="Country")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="country_id", referencedColumnName="id", nullable=true)
* })
*/
private $country;
/**
* @Assert\NotBlank(
* message = "User Profile not informed"
* )
*
* @Assert\Valid
*
* @var \UserProfile
*
* @ORM\ManyToOne(targetEntity="UserProfile")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user_profile_id", referencedColumnName="id", nullable=false)
* })
*/
private $userProfile;
/**
* @var \Session
*/
private $session;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Group", mappedBy="user")
*/
private $group;
/**
* @Assert\Valid
*
* @var \EADPlataforma\Entity\User
*
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user_delete_id", referencedColumnName="id", nullable=true)
* })
*/
private $userDelete;
/**
* @Assert\Choice(
* choices = {
* UserEnum::INDIVIDUAL,
* UserEnum::CASCADE
* },
* message = "Type Delete Invalid"
* )
*
* @var int
*
* @ORM\Column(name="type_delete", type="integer", nullable=true)
*/
private $typeDelete;
/**
* @EADAssert\DateTimeEAD(
* message = "Date Delete Invalid"
* )
*
* @var \DateTime|null
*
* @ORM\Column(name="date_delete", type="datetime", nullable=true)
*/
private $dateDelete;
/**
* Constructor
*/
public function __construct()
{
$this->setDateRegister(date('Y-m-d H:i:s'));
$this->group = new \Doctrine\Common\Collections\ArrayCollection();
$this->hashIdentify = md5(rand() . strtotime(date('Y-m-d H:i:s')));
$this->hashIdentify .= md5(
rand() . password_hash($this->hashIdentify, PASSWORD_DEFAULT)
);
}
public function getId(): ?int
{
return $this->id;
}
public function getHashIdentify(): ?string
{
return $this->hashIdentify;
}
public function setHashIdentify(?string $hashIdentify): self
{
$this->hashIdentify = $hashIdentify;
return $this;
}
public function getName(): ?string
{
return StringUtil::encodeStringStatic($this->name);
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = md5($password);
if($password == UserEnum::PASSWORD_RESET){
$this->password = $password;
}
return $this;
}
public function getOldPassword(?bool $origin = false): ?array
{
if($origin){
if(empty($this->oldPassword)){
return [];
}
return json_decode($this->oldPassword);
}
return $this->oldPassword;
}
public function setOldPassword(string $oldPassword): self
{
if(empty($this->oldPassword)){
$this->oldPassword = json_encode([ $oldPassword ]);
}
$oldPass = json_decode($this->oldPassword);
$oldPass[] = $oldPassword;
$this->oldPassword = json_encode($oldPass);
return $this;
}
public function getUsername(): ?string
{
return StringUtil::encodeStringStatic($this->username);
}
public function setUsername(string $username): self
{
$this->username = StringUtil::slugStatic($username, true);
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getOldStatus($string = false)
{
if($string){
return $this->stringStatus($this->oldStatus);
}
return $this->oldStatus;
}
public function setOldStatus(int $oldStatus): self
{
$this->oldStatus = $oldStatus;
return $this;
}
public function getStatus($string = false)
{
if($string){
return $this->stringStatus($this->status);
}
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getValidEmail()
{
return $this->validEmail;
}
public function setValidEmail(int $validEmail): self
{
$this->validEmail = $validEmail;
return $this;
}
public function getComplete()
{
return $this->complete;
}
public function setComplete(int $complete): self
{
$this->complete = $complete;
return $this;
}
public function getTeacherSpotlight()
{
return $this->teacherSpotlight;
}
public function setTeacherSpotlight(int $teacherSpotlight): self
{
$this->teacherSpotlight = $teacherSpotlight;
return $this;
}
public function getPermission(): ?string
{
return $this->permission;
}
public function setPermission(string $permission): self
{
$this->permission = $permission;
return $this;
}
public function getDateRegister($dateFormat = 'Y-m-d H:i:s')
{
if(!empty($this->dateRegister)){
return $this->dateRegister->format($dateFormat);
}
return $this->dateRegister;
}
public function setDateRegister($dateRegister): self
{
if(!empty($dateRegister)){
$dateRegister = DateTime::createFromFormat('Y-m-d H:i:s', $dateRegister);
}
$this->dateRegister = $dateRegister;
return $this;
}
public function getDateLastAccess($dateFormat = 'Y-m-d H:i:s')
{
if(!empty($this->dateLastAccess)){
return $this->dateLastAccess->format($dateFormat);
}
return $this->dateLastAccess;
}
public function setDateLastAccess($dateLastAccess): self
{
if(!empty($dateLastAccess)){
$dateLastAccess = DateTime::createFromFormat('Y-m-d H:i:s', $dateLastAccess);
}
$this->dateLastAccess = $dateLastAccess;
return $this;
}
public function getAuthenticationSecretKey(): ?string
{
return $this->authenticationSecretKey;
}
public function setAuthenticationSecretKey(?string $authenticationSecretKey): self
{
$this->authenticationSecretKey = $authenticationSecretKey;
return $this;
}
public function getAuthenticationCodeEmail(): ?string
{
return $this->authenticationCodeEmail;
}
public function setAuthenticationCodeEmail(?string $authenticationCodeEmail): self
{
$this->authenticationCodeEmail = $authenticationCodeEmail;
return $this;
}
public function getAuthenticationEmailDateExpire($dateFormat = 'Y-m-d H:i:s')
{
if(!empty($this->authenticationEmailDateExpire)){
return $this->authenticationEmailDateExpire->format($dateFormat);
}
return $this->authenticationEmailDateExpire;
}
public function setAuthenticationEmailDateExpire($authenticationEmailDateExpire): self
{
if(!empty($authenticationEmailDateExpire)){
$authenticationEmailDateExpire = DateTime::createFromFormat('Y-m-d H:i:s', $authenticationEmailDateExpire);
}
$this->authenticationEmailDateExpire = $authenticationEmailDateExpire;
return $this;
}
public function getAuthenticationAllow(): ?int
{
return $this->authenticationAllow;
}
public function setAuthenticationAllow(int $authenticationAllow): self
{
$this->authenticationAllow = $authenticationAllow;
return $this;
}
public function getAllowReceiver(): ?int
{
return $this->allowReceiver;
}
public function setAllowReceiver(int $allowReceiver): self
{
$this->allowReceiver = $allowReceiver;
return $this;
}
public function getAllowOneClickBuy(): ?int
{
return $this->allowOneClickBuy;
}
public function setAllowOneClickBuy(int $allowOneClickBuy): self
{
$this->allowOneClickBuy = $allowOneClickBuy;
return $this;
}
public function getAllowNotifyNewLesson(): ?int
{
return $this->allowNotifyNewLesson;
}
public function setAllowNotifyNewLesson(int $allowNotifyNewLesson): self
{
$this->allowNotifyNewLesson = $allowNotifyNewLesson;
return $this;
}
public function getAllowNotifyNewExam(): ?int
{
return $this->allowNotifyNewExam;
}
public function setAllowNotifyNewExam(int $allowNotifyNewExam): self
{
$this->allowNotifyNewExam = $allowNotifyNewExam;
return $this;
}
public function getAllowNotifyNewSupportMessage(): ?int
{
return $this->allowNotifyNewSupportMessage;
}
public function setAllowNotifyNewSupportMessage(int $allowNotifyNewSupportMessage): self
{
$this->allowNotifyNewSupportMessage = $allowNotifyNewSupportMessage;
return $this;
}
public function getAllowNotifyNewSupportAnswer(): ?int
{
return $this->allowNotifyNewSupportAnswer;
}
public function setAllowNotifyNewSupportAnswer(int $allowNotifyNewSupportAnswer): self
{
$this->allowNotifyNewSupportAnswer = $allowNotifyNewSupportAnswer;
return $this;
}
public function getAllowNotifyNewMessage(): ?int
{
return $this->allowNotifyNewMessage;
}
public function setAllowNotifyNewMessage(int $allowNotifyNewMessage): self
{
$this->allowNotifyNewMessage = $allowNotifyNewMessage;
return $this;
}
public function getAllowNotifyNewGroupMessage(): ?int
{
return $this->allowNotifyNewGroupMessage;
}
public function setAllowNotifyNewGroupMessage(int $allowNotifyNewGroupMessage): self
{
$this->allowNotifyNewGroupMessage = $allowNotifyNewGroupMessage;
return $this;
}
public function getAllowNotifyCart(): ?int
{
return $this->allowNotifyCart;
}
public function setAllowNotifyCart(int $allowNotifyCart): self
{
$this->allowNotifyCart = $allowNotifyCart;
return $this;
}
public function getDocument(): ?string
{
return $this->document;
}
public function setDocument(?string $document): self
{
$this->document = $document;
return $this;
}
public function getPhoto(?bool $complete = false): ?string
{
if($complete){
return FileService::getFilePathComplete(
$this->photo,
UserEnum::PATH_PROFILES,
true,
true
);
}
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getCover(): ?string
{
return $this->cover;
}
public function setCover(?string $cover): self
{
$this->cover = $cover;
return $this;
}
public function getOccupation(): ?string
{
return StringUtil::encodeStringStatic($this->occupation);
}
public function setOccupation(?string $occupation): self
{
$this->occupation = $occupation;
return $this;
}
public function getBiography(): ?string
{
return StringUtil::encodeStringStatic($this->biography);
}
public function setBiography(?string $biography): self
{
$this->biography = $biography;
return $this;
}
public function getResume(): ?string
{
return StringUtil::encodeStringStatic($this->resume);
}
public function setResume(?string $resume): self
{
$this->resume = $resume;
return $this;
}
public function getCustom(): ?string
{
return StringUtil::encodeStringStatic($this->custom);
}
public function setCustom(?string $custom): self
{
$this->custom = $custom;
return $this;
}
public function getNotes(): ?string
{
return StringUtil::encodeStringStatic($this->notes);
}
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
public function getBirthDate($dateFormat = 'Y-m-d')
{
if(!empty($this->birthDate)){
return $this->birthDate->format($dateFormat);
}
return $this->birthDate;
}
public function setBirthDate($birthDate): self
{
if(!empty($birthDate)){
$birthDate = DateTime::createFromFormat('Y-m-d', $birthDate);
}else{
$birthDate = null;
}
$this->birthDate = $birthDate;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
public function setZipCode(?string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getAddress(): ?string
{
return StringUtil::encodeStringStatic($this->address);
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getAddressNumber(): ?string
{
return $this->addressNumber;
}
public function setAddressNumber(?string $addressNumber): self
{
$this->addressNumber = $addressNumber;
return $this;
}
public function getAddressComplement(): ?string
{
return $this->addressComplement;
}
public function setAddressComplement(?string $addressComplement): self
{
$this->addressComplement = $addressComplement;
return $this;
}
public function getAddressNeighborhood(): ?string
{
return StringUtil::encodeStringStatic($this->addressNeighborhood);
}
public function setAddressNeighborhood(?string $addressNeighborhood): self
{
$this->addressNeighborhood = $addressNeighborhood;
return $this;
}
public function getCustomField(): ?string
{
return StringUtil::encodeStringStatic($this->customField);
}
public function setCustomField(?string $customField): self
{
$this->customField = $customField;
return $this;
}
public function getWebsite(): ?string
{
return $this->website;
}
public function setWebsite(?string $website): self
{
$this->website = $website;
return $this;
}
public function getTwitter(): ?string
{
return $this->twitter;
}
public function setTwitter(?string $twitter): self
{
$this->twitter = $twitter;
return $this;
}
public function getFacebook(): ?string
{
return $this->facebook;
}
public function setFacebook(?string $facebook): self
{
$this->facebook = $facebook;
return $this;
}
public function getLinkedin(): ?string
{
return $this->linkedin;
}
public function setLinkedin(?string $linkedin): self
{
$this->linkedin = $linkedin;
return $this;
}
public function getYoutube(): ?string
{
return $this->youtube;
}
public function setYoutube(?string $youtube): self
{
$this->youtube = $youtube;
return $this;
}
public function getInstagram(): ?string
{
return $this->instagram;
}
public function setInstagram(?string $instagram): self
{
$this->instagram = $instagram;
return $this;
}
public function getTiktok(): ?string
{
return $this->tiktok;
}
public function setTiktok(?string $tiktok): self
{
$this->tiktok = $tiktok;
return $this;
}
public function getInvited(): ?int
{
return $this->invited;
}
public function setInvited(?int $invited): self
{
$this->invited = $invited;
return $this;
}
public function getConfirmationDate($dateFormat = 'Y-m-d H:i:s')
{
if(!empty($this->confirmationDate)){
return $this->confirmationDate->format($dateFormat);
}
return $this->confirmationDate;
}
public function setConfirmationDate($confirmationDate): self
{
if(!empty($confirmationDate)){
$confirmationDate = DateTime::createFromFormat('Y-m-d H:i:s', $confirmationDate);
}
$this->confirmationDate = $confirmationDate;
return $this;
}
public function getRecoverDate($dateFormat = 'Y-m-d')
{
if(!empty($this->recoverDate)){
return $this->recoverDate->format($dateFormat);
}
return $this->recoverDate;
}
public function setRecoverDate($recoverDate): self
{
if(!empty($recoverDate)){
$recoverDate = DateTime::createFromFormat('Y-m-d', $recoverDate);
}
$this->recoverDate = $recoverDate;
return $this;
}
public function getRecoverAttempt(): ?int
{
return $this->recoverAttempt;
}
public function setRecoverAttempt(?int $recoverAttempt): self
{
$this->recoverAttempt = $recoverAttempt;
return $this;
}
public function getScreenSize(): ?int
{
return $this->screenSize;
}
public function setScreenSize(?int $screenSize): self
{
$this->screenSize = $screenSize;
return $this;
}
public function getAutoplay(): ?int
{
return $this->autoplay;
}
public function setAutoplay(?int $autoplay): self
{
$this->autoplay = $autoplay;
return $this;
}
public function getAcceptTerms(): ?int
{
return $this->acceptTerms;
}
public function setAcceptTerms(?int $acceptTerms): self
{
$this->acceptTerms = $acceptTerms;
return $this;
}
public function getAcceptTermsContract(): ?string
{
return StringUtil::encodeStringStatic($this->acceptTermsContract);
}
public function setAcceptTermsContract(?string $acceptTermsContract): self
{
$this->acceptTermsContract = $acceptTermsContract;
return $this;
}
public function getAcceptTermsDate($dateFormat = 'Y-m-d H:i:s')
{
if($this->acceptTermsDate){
return $this->acceptTermsDate->format($dateFormat);
}
return $this->acceptTermsDate;
}
public function setAcceptTermsDate($acceptTermsDate): self
{
if(!empty($acceptTermsDate)){
$acceptTermsDate = DateTime::createFromFormat('Y-m-d H:i:s', $acceptTermsDate);
}
$this->acceptTermsDate = $acceptTermsDate;
return $this;
}
public function getPipedrivePerson(): ?int
{
return $this->pipedrivePerson;
}
public function setPipedrivePerson(?int $pipedrivePerson): self
{
$this->pipedrivePerson = $pipedrivePerson;
return $this;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getState(): ?State
{
return $this->state;
}
public function setState(?State $state): self
{
$this->state = $state;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function getUserProfile(): ?UserProfile
{
return $this->userProfile;
}
public function setUserProfile(?UserProfile $userProfile): self
{
$this->userProfile = $userProfile;
return $this;
}
public function getSession(): ?Session
{
return $this->session;
}
public function setSession(?Session $session): self
{
$this->session = $session;
return $this;
}
public function getUserDelete(): ?User
{
return $this->userDelete;
}
public function setUserDelete(?User $userDelete): self
{
$this->userDelete = $userDelete;
return $this;
}
public function getDateDelete($dateFormat = 'Y-m-d H:i:s')
{
if($this->dateDelete){
return $this->dateDelete->format($dateFormat);
}
return $this->dateDelete;
}
public function setDateDelete($dateDelete): self
{
if(!empty($dateDelete)){
$dateDelete = DateTime::createFromFormat('Y-m-d H:i:s', $dateDelete);
}
$this->dateDelete = $dateDelete;
return $this;
}
/**
* @return Collection|Group[]
*/
public function getGroup(): Collection
{
return $this->group;
}
public function addGroup(\EADPlataforma\Entity\Group $group): self
{
if (!$this->group->contains($group)) {
$this->group[] = $group;
$group->addUser($this);
}
return $this;
}
public function removeGroup(\EADPlataforma\Entity\Group $group): self
{
if ($this->group->contains($group)) {
$this->group->removeElement($group);
$group->removeUser($this);
}
return $this;
}
public function removeAllGroup(): self
{
$this->group = new \Doctrine\Common\Collections\ArrayCollection();
return $this;
}
// ******* UserInterface ******* //
public function getRoles() {
return [ 'ROLE_USER' ];
}
public function getSalt() {
}
public function eraseCredentials() {
}
// ******* UserInterface ******* //
public function individual(): self
{
$this->typeDelete = UserEnum::INDIVIDUAL;
return $this;
}
public function cascade(): self
{
$this->typeDelete = UserEnum::CASCADE;
return $this;
}
public function isLive(): bool
{
return ($this->deleted == UserEnum::ITEM_NO_DELETED);
}
public function isOnTrash(): bool
{
return ($this->deleted == UserEnum::ITEM_ON_TRASH);
}
public function isDeleted(): bool
{
return ($this->deleted == UserEnum::ITEM_DELETED);
}
public function restore(): self
{
$this->deleted = UserEnum::ITEM_NO_DELETED;
return $this;
}
public function trash(): self
{
$this->deleted = UserEnum::ITEM_ON_TRASH;
return $this;
}
public function delete(): self
{
$this->deleted = UserEnum::ITEM_DELETED;
return $this;
}
public function stringStatus($status){
$string = '';
switch ($status) {
case UserEnum::WAITING:
$string = 'Waiting';
break;
case UserEnum::ACTIVE:
$string = 'Active';
break;
case UserEnum::BLOCK:
$string = 'Blocked';
break;
case UserEnum::INACTIVE:
$string = 'Inactive';
break;
}
return $string;
}
public function toReturnClean(){
$data = [
"name" => $this->getName(),
"email" => $this->email,
"username" => $this->getUsername(),
"dateRegister" => $this->getDateRegister(),
"document" => $this->document,
"photo" => FileService::getFilePathComplete(
$this->photo,
UserEnum::PATH_PROFILES,
true,
true
),
"cover" => FileService::getFilePathComplete(
$this->cover,
UserEnum::PATH_COVERS_PROFILE,
true,
true
),
"birthDate" => $this->getBirthDate(),
"phone" => $this->phone,
"zipCode" => $this->zipCode,
"address" => $this->getAddress(),
"addressNumber" => $this->addressNumber,
"addressComplement" => $this->addressComplement,
"addressNeighborhood" => $this->getAddressNeighborhood(),
"city" => ( $this->city ? $this->city->getId() : null ),
"state" => ( $this->state ? $this->state->getId() : null ),
"country" => ( $this->country ? $this->country->getId() : null ),
"cityName" => ( $this->city ? $this->city->getName() : null ),
"stateName" => ( $this->state ? $this->state->getName() : null ),
"countryName" => ( $this->country ? $this->country->getName() : null ),
];
return $data;
}
public function toReturn($isProfile = false){
$arrGroup = [];
foreach ($this->group as $key => $group) {
$arrGroup[] = $group->getId();
}
$data = [
"complete" => $this->complete,
"teacherSpotlight" => $this->teacherSpotlight,
"name" => $this->getName(),
"email" => $this->email,
"password" => $this->password,
"username" => $this->getUsername(),
"dateRegister" => $this->getDateRegister(),
"authenticationSecretKey" => $this->authenticationSecretKey,
"authenticationCodeEmail" => $this->authenticationCodeEmail,
"authenticationEmailDateExpire" => $this->authenticationEmailDateExpire,
"authenticationAllow" => $this->authenticationAllow,
"allowReceiver" => $this->allowReceiver,
"allowOneClickBuy" => $this->allowOneClickBuy,
"allowNotifyNewLesson" => $this->allowNotifyNewLesson,
"allowNotifyNewExam" => $this->allowNotifyNewExam,
"allowNotifyNewSupportMessage" => $this->allowNotifyNewSupportMessage,
"allowNotifyNewSupportAnswer" => $this->allowNotifyNewSupportAnswer,
"allowNotifyNewMessage" => $this->allowNotifyNewMessage,
"allowNotifyNewGroupMessage" => $this->allowNotifyNewGroupMessage,
"allowNotifyCart" => $this->allowNotifyCart,
"document" => $this->document,
"photo" => FileService::getFilePathComplete(
$this->photo,
UserEnum::PATH_PROFILES,
true,
true
),
"cover" => FileService::getFilePathComplete(
$this->cover,
UserEnum::PATH_COVERS_PROFILE,
true,
true
),
"occupation" => $this->getOccupation(),
"biography" => $this->getBiography(),
"resume" => $this->getResume(),
"custom" => $this->getCustom(),
"notes" => $this->getNotes(),
"birthDate" => $this->getBirthDate(),
"phone" => $this->phone,
"zipCode" => $this->zipCode,
"address" => $this->getAddress(),
"addressNumber" => $this->addressNumber,
"addressComplement" => $this->addressComplement,
"addressNeighborhood" => $this->getAddressNeighborhood(),
"customField" => $this->getCustomField(),
"website" => $this->website,
"twitter" => $this->twitter,
"facebook" => $this->facebook,
"linkedin" => $this->linkedin,
"youtube" => $this->youtube,
"instagram" => $this->instagram,
"tiktok" => $this->tiktok,
"pipedrivePerson" => $this->pipedrivePerson,
"city" => ( $this->city ? $this->city->getId() : null ),
"state" => ( $this->state ? $this->state->getId() : null ),
"country" => ( $this->country ? $this->country->getId() : null ),
"cityName" => ( $this->city ? $this->city->getName() : null ),
"stateName" => ( $this->state ? $this->state->getName() : null ),
"countryName" => ( $this->country ? $this->country->getName() : null ),
"userDelete" => ( $this->userDelete ? $this->userDelete->getId() : null ),
"typeDelete" => $this->typeDelete,
"dateDelete" => $this->getDateDelete()
];
if(!$isProfile){
$data["id"] = $this->id;
$data["deleted"] = $this->deleted;
$data["hashIdentify"] = $this->hashIdentify;
$data["userProfile"] = (
$this->userProfile ? $this->userProfile->getId() : null
);
$data["userProfileName"] = (
$this->userProfile ? $this->userProfile->getName() : null
);
$data["type"] = $this->type;
$data["oldStatus"] = $this->oldStatus;
$data["status"] = $this->status;
$data["validEmail"] = $this->validEmail;
$data["permission"] = $this->permission;
$data["invited"] = $this->invited;
$data["confirmationDate"] = $this->getConfirmationDate();
$data["recoverDate"] = $this->getRecoverDate();
$data["recoverAttempt"] = $this->recoverAttempt;
$data["screenSize"] = $this->screenSize;
$data["autoplay"] = $this->autoplay;
$data["acceptTerms"] = $this->acceptTerms;
$data["acceptTermsContract"] = $this->acceptTermsContract;
$data["acceptTermsDate"] = $this->getAcceptTermsDate();
$data["session"] = ( $this->session ? $this->session->getId() : null );
$data["group"] = $arrGroup;
}
return $data;
}
public function toWebhook()
{
return (object)[
"id" => (string)$this->getId(),
"name" => (string)$this->getName(),
"email" => (string)$this->getEmail(),
"phone" => (string)$this->getPhone(),
"status" => (int)$this->getStatus(),
"address" => [
"street" => $this->getAddress(),
"number" => $this->getAddressNumber(),
"complement" => $this->getAddressComplement(),
"neighborhood" => $this->getAddressNeighborhood(),
"city" => ($this->getCity() ? $this->getCity()->getName() : null),
"state" => ($this->getState() ? $this->getState()->getUf() : null),
"zipcode" => $this->getZipCode(),
"country" => ($this->getCountry() ? $this->getCountry()->getName() : null),
],
"dates" => (object)[
"signup" => (string)$this->getDateRegister('Y-m-d H:i:s'),
"confirmation" => (string)$this->getConfirmationDate('Y-m-d H:i:s'),
],
];
}
public function toReturnApi(){
$arrGroup = [];
foreach ($this->group as $key => $group) {
$arrGroup[] = $group->getId();
}
$data = [
"aluno_id" => $this->id,
"nome" => $this->getName(),
"email" => $this->email,
"senha" => $this->password,
"username" => $this->getUsername(),
"tipo" => $this->type,
"permissao_id" => ( $this->userProfile ? $this->userProfile->getId() : null ),
"oldStatus" => $this->oldStatus,
"status" => $this->status,
"cpf" => $this->document,
"foto" => FileService::getFilePathComplete(
$this->photo,
UserEnum::PATH_PROFILES,
true,
true
),
"ocupacao" => $this->getOccupation(),
"personalizado" => $this->getCustom(),
"anotacoes" => $this->getNotes(),
"nascimento" => $this->getBirthDate(),
"telefone" => $this->phone,
"cep" => $this->zipCode,
"endereco" => $this->getAddress(),
"numero" => $this->addressNumber,
"complemento" => $this->addressComplement,
"bairro" => $this->getAddressNeighborhood(),
];
return $data;
}
}