diff --git a/src/Entity/Employee.php b/src/Entity/Employee.php index 488f48e..578c4df 100644 --- a/src/Entity/Employee.php +++ b/src/Entity/Employee.php @@ -3,22 +3,98 @@ namespace App\Entity; +use Doctrine\Common\Collections\Collection; +use App\Repository\EmployeeRepository; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; +use Symfony\Component\Security\Core\User\UserInterface; - -class Employee +#[ORM\Entity(repositoryClass: EmployeeRepository::class)] +#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])] +class Employee implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; + #[ORM\Column(length: 180)] + private ?string $email = null; + #[ORM\Column(length: 30)] private ?string $firstName = null; #[ORM\Column(length: 30)] private ?string $lastName = null; + #[ORM\Column] + private ?string $password = null; + + #[ORM\ManyToOne(targetEntity: EmployeeSkill::class, inversedBy: 'employee')] + private Collection $employeeskills; + + #[ORM\ManyToOne(targetEntity: Mission::class, inversedBy: 'employee')] + private Collection $missions; + + #[ORM\ManyToOne(targetEntity: Incident::class, inversedBy: 'employee')] + private Collection $incidents; + + #[ORM\ManyToOne(targetEntity: Assignment::class, inversedBy: 'employee')] + private Collection $assignments; + + #[ORM\ManyToOne(targetEntity: Representation::class, inversedBy: 'employee')] + private Collection $representations; + + public function getEmployeeskills(): Collection + { + return $this->employeeskills; + } + + public function setEmployeeskills(Collection $employeeskills): void + { + $this->employeeskills = $employeeskills; + } + + public function getEmployeemissions(): Collection + { + return $this->employeemissions; + } + + public function setEmployeemissions(Collection $employeemissions): void + { + $this->employeemissions = $employeemissions; + } + + public function getEmployeeincidents(): Collection + { + return $this->employeeincidents; + } + + public function setEmployeeincidents(Collection $employeeincidents): void + { + $this->employeeincidents = $employeeincidents; + } + + public function getAssignments(): Collection + { + return $this->assignments; + } + + public function setAssignments(Collection $assignments): void + { + $this->assignments = $assignments; + } + + public function getRepresentations(): Collection + { + return $this->representations; + } + + public function setRepresentations(Collection $representations): void + { + $this->representations = $representations; + } + public function getId(): ?int { return $this->id; @@ -31,6 +107,18 @@ class Employee return $this; } + public function getEmail(): ?string + { + return $this->email; + } + + public function setEmail(string $email): static + { + $this->email = $email; + + return $this; + } + public function getFirstName(): ?string { return $this->firstName; @@ -54,4 +142,27 @@ class Employee return $this; } + + public function getPassword(): ?string + { + return $this->password; + } + + public function setPassword(string $password): static + { + $this->password = $password; + + return $this; + } + + public function eraseCredentials(): void + { + // If you store any temporary, sensitive data on the user, clear it here + // $this->plainPassword = null; + } + + public function getUserIdentifier(): string + { + return (string) $this->email; + } } diff --git a/src/Entity/EmployeeIncident.php b/src/Entity/EmployeeIncident.php deleted file mode 100644 index 87959d0..0000000 --- a/src/Entity/EmployeeIncident.php +++ /dev/null @@ -1,19 +0,0 @@ -id; - } -} diff --git a/src/Entity/MissionCategory.php b/src/Entity/MissionCategory.php new file mode 100644 index 0000000..76a4d1c --- /dev/null +++ b/src/Entity/MissionCategory.php @@ -0,0 +1,20 @@ + + */ +class EmployeeRepository extends ServiceEntityRepository implements PasswordUpgraderInterface +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Employee::class); + } + + /** + * Used to upgrade (rehash) the user's password automatically over time. + */ + public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void + { + if (!$user instanceof Employee) { + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class)); + } + + $user->setPassword($newHashedPassword); + $this->getEntityManager()->persist($user); + $this->getEntityManager()->flush(); + } + + // /** + // * @return Employee[] Returns an array of Employee objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('e') + // ->andWhere('e.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('e.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Employee + // { + // return $this->createQueryBuilder('e') + // ->andWhere('e.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/MissionCategoryRepository.php b/src/Repository/MissionCategoryRepository.php new file mode 100644 index 0000000..034ae82 --- /dev/null +++ b/src/Repository/MissionCategoryRepository.php @@ -0,0 +1,43 @@ + + */ +class MissionCategoryRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, MissionCategory::class); + } + + // /** + // * @return MissionCategory[] Returns an array of MissionCategory objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('m') + // ->andWhere('m.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('m.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?MissionCategory + // { + // return $this->createQueryBuilder('m') + // ->andWhere('m.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}