2024-11-28 11:37:56 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
|
|
|
use App\Repository\UserRepository;
|
|
|
|
use App\Enums\RateType;
|
2024-12-03 00:00:09 -05:00
|
|
|
use App\Enums\CaseLevel;
|
2024-11-28 11:37:56 -05:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\DBAL\Types\Types;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use Symfony\Bridge\Doctrine\Types\UuidType;
|
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
|
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
|
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
|
use Symfony\Component\Uid\Uuid;
|
2025-01-03 10:31:07 -05:00
|
|
|
use Vich\UploaderBundle\Entity\File;
|
|
|
|
use Vich\UploaderBundle\Mapping\Annotation as Vich;
|
2024-11-28 11:37:56 -05:00
|
|
|
|
|
|
|
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
|
|
|
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
|
|
|
|
#[UniqueEntity(fields: ['username'], message: 'There is already an account with this username')]
|
2025-01-03 10:31:07 -05:00
|
|
|
#[Vich\Uploadable]
|
2024-11-28 11:37:56 -05:00
|
|
|
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
|
{
|
|
|
|
#[ORM\Id]
|
|
|
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
|
|
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
|
|
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
|
|
|
private ?Uuid $id = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 45)]
|
|
|
|
private ?string $username = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var list<string> The user roles
|
|
|
|
*/
|
|
|
|
#[ORM\Column]
|
|
|
|
private array $roles = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The hashed password
|
|
|
|
*/
|
|
|
|
#[ORM\Column]
|
|
|
|
private ?string $password = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 45)]
|
|
|
|
private ?string $name = null;
|
|
|
|
|
2024-12-18 21:39:35 -05:00
|
|
|
#[ORM\Column(length: 64)]
|
2024-11-28 11:37:56 -05:00
|
|
|
private ?string $email = null;
|
|
|
|
|
|
|
|
#[ORM\Column(enumType: RateType::class)]
|
|
|
|
private ?RateType $rateType = null;
|
|
|
|
|
|
|
|
#[ORM\Column(type: Types::DECIMAL, precision: 6, scale: 2)]
|
|
|
|
private ?string $rate = null;
|
|
|
|
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'users')]
|
|
|
|
#[ORM\JoinColumn(nullable: true)]
|
|
|
|
private ?Company $company = null;
|
|
|
|
|
|
|
|
#[ORM\Column(enumType: CaseLevel::class)]
|
|
|
|
private ?CaseLevel $level = null;
|
|
|
|
|
2024-11-30 19:58:48 -05:00
|
|
|
private ?User $supervisor = null;
|
2024-11-29 21:47:37 -05:00
|
|
|
|
2024-12-03 00:00:09 -05:00
|
|
|
#[ORM\Column]
|
|
|
|
private ?bool $caseWorker = null;
|
|
|
|
|
|
|
|
#[ORM\Column]
|
|
|
|
private ?bool $caseManager = null;
|
|
|
|
|
|
|
|
#[ORM\Column]
|
|
|
|
private ?bool $therapist = null;
|
|
|
|
|
|
|
|
#[ORM\Column]
|
|
|
|
private ?bool $su = null;
|
|
|
|
|
2024-12-07 22:52:49 -05:00
|
|
|
/**
|
|
|
|
* @var Collection<int, UserCase>
|
|
|
|
*/
|
|
|
|
#[ORM\OneToMany(targetEntity: UserCase::class, mappedBy: 'user')]
|
|
|
|
private Collection $userCases;
|
|
|
|
|
2025-01-03 10:31:07 -05:00
|
|
|
#[Vich\UploadableField(mapping: 'profile_image', fileNameProperty: 'imageName', size: 'size', mimeType: 'mimeType', originalName: 'originalName', dimensions: 'dimensions')]
|
|
|
|
private ?File $imageFile = null;
|
|
|
|
|
|
|
|
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
|
|
|
|
private ?string $imageName = null;
|
|
|
|
|
|
|
|
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
|
|
|
private ?\DateTimeInterface $passwordChanged = null;
|
|
|
|
|
2025-01-05 01:08:02 -05:00
|
|
|
#[ORM\Column(length: 15, nullable: true)]
|
|
|
|
private ?string $personalPhone = null;
|
|
|
|
|
|
|
|
#[ORM\Column(length: 15)]
|
|
|
|
private ?string $workPhone = null;
|
|
|
|
|
2024-11-28 11:37:56 -05:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->userCases = new ArrayCollection();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getId(): ?Uuid
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUsername(): ?string
|
|
|
|
{
|
|
|
|
return $this->username;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUsername(string $username): static
|
|
|
|
{
|
|
|
|
$this->username = $username;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A visual identifier that represents this user.
|
|
|
|
*
|
|
|
|
* @see UserInterface
|
|
|
|
*/
|
|
|
|
public function getUserIdentifier(): string
|
|
|
|
{
|
|
|
|
return (string) $this->username;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see UserInterface
|
|
|
|
*
|
|
|
|
* @return list<string>
|
|
|
|
*/
|
|
|
|
public function getRoles(): array
|
|
|
|
{
|
|
|
|
$roles = $this->roles;
|
|
|
|
// guarantee every user at least has ROLE_USER
|
|
|
|
$roles[] = 'ROLE_USER';
|
|
|
|
|
|
|
|
return array_unique($roles);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param list<string> $roles
|
|
|
|
*/
|
|
|
|
public function setRoles(array $roles): static
|
|
|
|
{
|
|
|
|
$this->roles = $roles;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see PasswordAuthenticatedUserInterface
|
|
|
|
*/
|
|
|
|
public function getPassword(): ?string
|
|
|
|
{
|
|
|
|
return $this->password;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPassword(string $password): static
|
|
|
|
{
|
|
|
|
$this->password = $password;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see UserInterface
|
|
|
|
*/
|
|
|
|
public function eraseCredentials(): void
|
|
|
|
{
|
|
|
|
// 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): static
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEmail(): ?string
|
|
|
|
{
|
|
|
|
return $this->email;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEmail(string $email): static
|
|
|
|
{
|
|
|
|
$this->email = $email;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRateType(): ?RateType
|
|
|
|
{
|
|
|
|
return $this->rateType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRateType(RateType $rateType): static
|
|
|
|
{
|
|
|
|
$this->rateType = $rateType;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRate(): ?string
|
|
|
|
{
|
|
|
|
return $this->rate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRate(string $rate): static
|
|
|
|
{
|
|
|
|
$this->rate = $rate;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection<int, UserCase>
|
|
|
|
*/
|
|
|
|
public function getUserCases(): Collection
|
|
|
|
{
|
|
|
|
return $this->userCases;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCompany(): ?Company
|
|
|
|
{
|
|
|
|
return $this->company;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCompany(?Company $company): static
|
|
|
|
{
|
|
|
|
$this->company = $company;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLevel(): ?CaseLevel
|
|
|
|
{
|
|
|
|
return $this->level;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLevel(CaseLevel $level): static
|
|
|
|
{
|
|
|
|
$this->level = $level;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2024-11-29 21:47:37 -05:00
|
|
|
|
|
|
|
public function retrieveUnreadNotifications(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'id' => 1,
|
|
|
|
'title' => 'Welcome',
|
|
|
|
'from' => 'Admin',
|
|
|
|
'type' => 'info',
|
|
|
|
'message' => 'Welcome to the dashboard.',
|
|
|
|
'timestamp' => new \DateTime('2024-11-12 10:00:00'),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 2,
|
|
|
|
'title' => 'New Case',
|
|
|
|
'from' => 'Admin',
|
|
|
|
'type' => 'info',
|
|
|
|
'message' => 'You have a new case.',
|
|
|
|
'timestamp' => new \DateTime('2024-11-13 10:19:56'),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'id' => 3,
|
|
|
|
'title' => 'New Message',
|
|
|
|
'from' => 'Admin',
|
|
|
|
'type' => 'warning',
|
|
|
|
'message' => 'You have a new message.',
|
|
|
|
'timestamp' => new \DateTime('2024-11-16 11:13:25'),
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-11-30 19:58:48 -05:00
|
|
|
public function getSupervisor(): ?User
|
2024-11-29 21:47:37 -05:00
|
|
|
{
|
|
|
|
return $this->supervisor;
|
|
|
|
}
|
|
|
|
|
2024-11-30 19:58:48 -05:00
|
|
|
public function setSupervisor(?User $supervisor): static
|
2024-11-29 21:47:37 -05:00
|
|
|
{
|
|
|
|
$this->supervisor = $supervisor;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2024-12-03 00:00:09 -05:00
|
|
|
|
|
|
|
public function isCaseWorker(): ?bool
|
|
|
|
{
|
|
|
|
return $this->caseWorker;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCaseWorker(bool $caseWorker): static
|
|
|
|
{
|
|
|
|
$this->caseWorker = $caseWorker;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isCaseManager(): ?bool
|
|
|
|
{
|
|
|
|
return $this->caseManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCaseManager(bool $caseManager): static
|
|
|
|
{
|
|
|
|
$this->caseManager = $caseManager;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isTherapist(): ?bool
|
|
|
|
{
|
|
|
|
return $this->therapist;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTherapist(bool $therapist): static
|
|
|
|
{
|
|
|
|
$this->therapist = $therapist;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isSu(): ?bool
|
|
|
|
{
|
|
|
|
return $this->su;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSu(bool $su): static
|
|
|
|
{
|
|
|
|
$this->su = $su;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getJobs(): array
|
|
|
|
{
|
|
|
|
$jobs = [];
|
|
|
|
if ($this->caseWorker) {
|
|
|
|
$jobs[] = 'Case Worker';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->caseManager) {
|
|
|
|
$jobs[] = 'Case Manager';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->therapist) {
|
|
|
|
$jobs[] = 'Therapist';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->su) {
|
|
|
|
$jobs[] = 'Admin';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $jobs;
|
|
|
|
}
|
2025-01-03 10:31:07 -05:00
|
|
|
|
|
|
|
public function getImageFile(): ?File
|
|
|
|
{
|
|
|
|
return $this->imageFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setImageFile(?File $imageFile): static
|
|
|
|
{
|
|
|
|
$this->imageFile = $imageFile;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getImageName(): ?string
|
|
|
|
{
|
|
|
|
return $this->imageName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setImageName(?string $imageName): static
|
|
|
|
{
|
|
|
|
$this->imageName = $imageName;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPasswordChanged(): ?\DateTimeInterface
|
|
|
|
{
|
|
|
|
return $this->passwordChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPasswordChanged(\DateTimeInterface $passwordChanged): static
|
|
|
|
{
|
|
|
|
$this->passwordChanged = $passwordChanged;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2025-01-05 01:08:02 -05:00
|
|
|
|
|
|
|
public function getPersonalPhone(): ?string
|
|
|
|
{
|
|
|
|
return $this->personalPhone;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPersonalPhone(?string $personalPhone): static
|
|
|
|
{
|
|
|
|
$this->personalPhone = $personalPhone;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getWorkPhone(): ?string
|
|
|
|
{
|
|
|
|
return $this->workPhone;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setWorkPhone(string $workPhone): static
|
|
|
|
{
|
|
|
|
$this->workPhone = $workPhone;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFormattedPhone(): ?string
|
|
|
|
{
|
|
|
|
$ret = '';
|
|
|
|
if ($this->workPhone) {
|
|
|
|
$ret = '(' . substr($this->workPhone, 0, 3) . ') ' . substr($this->workPhone, 3, 3) . '-' . substr($this->workPhone, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
}
|
2024-11-28 11:37:56 -05:00
|
|
|
}
|