<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\Mapping\UniqueConstraint;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
/**
* @ORM\Table(name="User",
* uniqueConstraints={
* @UniqueConstraint(name="email",
* columns={"email"}),
* @UniqueConstraint(name="subdomain",
* columns={"subdomain"})
* },
*
* )
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
* @ORM\HasLifecycleCallbacks()
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
use Timestamps;
use SoftDeleteableEntity;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(name="company_name", type="string", length=180)
*/
private $companyName;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @ORM\Column(type="string", length=180)
*/
private $name;
/**
* @ORM\Column(type="string", length=180)
*/
private $surname;
/**
* @ORM\Column(type="string", length=20)
*/
private $phone;
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(name="is_managent_active", type="boolean", options={"default"="0"})
*/
private $isManagentActive;
/**
* @ORM\Column(name="is_verified", type="boolean", nullable="false")
*/
private $isVerified = false;
/**
* @ORM\Column(type="string", length=50, unique=true, nullable="true")
*/
private $subdomain;
public function __construct()
{
$this->setRoles(array('ROLE_CUSTOMER'));
$this->setIsManagentActive(0);
}
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 getUserIdentifier(): 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;
}
/**
* @param mixed $companyName
*/
public function setCompanyName($companyName)
{
$this->companyName = $companyName;
}
/**
* @return mixed
*/
public function getCompanyName()
{
return $this->companyName;
}
/**
* @param mixed $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $surname
*/
public function setSurname($surname)
{
$this->surname = $surname;
}
/**
* @return mixed
*/
public function getSurname()
{
return $this->surname;
}
/**
* @param mixed $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* @return mixed
*/
public function getPhone()
{
return $this->phone;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return mixed
*/
public function getIsManagentActive()
{
return $this->isManagentActive;
}
/**
* @param mixed $isManagentActive
*/
public function setIsManagentActive($isManagentActive)
{
$this->isManagentActive = $isManagentActive;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
/**
* @return mixed
*/
public function getSubdomain()
{
return $this->subdomain;
}
/**
* @param mixed $subdomain
*/
public function setSubdomain($subdomain)
{
$this->subdomain = $subdomain;
}
public function getUsername()
{
// TODO: Implement getUsername() method.
}
}