Finished entities
This commit is contained in:
parent
1531c122b8
commit
f0c7c03b9b
@ -3,22 +3,98 @@
|
|||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use App\Repository\EmployeeRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: EmployeeRepository::class)]
|
||||||
class Employee
|
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
|
||||||
|
class Employee implements UserInterface, PasswordAuthenticatedUserInterface
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 180)]
|
||||||
|
private ?string $email = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 30)]
|
#[ORM\Column(length: 30)]
|
||||||
private ?string $firstName = null;
|
private ?string $firstName = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 30)]
|
#[ORM\Column(length: 30)]
|
||||||
private ?string $lastName = null;
|
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
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@ -31,6 +107,18 @@ class Employee
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEmail(): ?string
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmail(string $email): static
|
||||||
|
{
|
||||||
|
$this->email = $email;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getFirstName(): ?string
|
public function getFirstName(): ?string
|
||||||
{
|
{
|
||||||
return $this->firstName;
|
return $this->firstName;
|
||||||
@ -54,4 +142,27 @@ class Employee
|
|||||||
|
|
||||||
return $this;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
#[ORM\Table(name: 'EmployeeIncident')]
|
|
||||||
class EmployeeIncident
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\OneToMany(targetEntity: Employee::class, mappedBy: 'EmployeeIncidents')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
|
||||||
private ?Employee $employee = null;
|
|
||||||
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\OneToMany(targetEntity: Incident::class, mappedBy: 'EmployeeIncidents')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
|
||||||
private ?Incident $incident = null;
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use App\Repository\EmployeeMissionRepository;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: EmployeeMissionRepository::class)]
|
|
||||||
class EmployeeMission
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
}
|
|
20
src/Entity/MissionCategory.php
Normal file
20
src/Entity/MissionCategory.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\MissionCategoryRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: MissionCategoryRepository::class)]
|
||||||
|
class MissionCategory
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\OneToMany(targetEntity: Mission::class, mappedBy: 'MissionCategory')]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
private ?Mission $mission = null;
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\OneToMany(targetEntity: Category::class, mappedBy: 'MissionCategory')]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
private ?Category $category = null;
|
||||||
|
}
|
60
src/Repository/EmployeeRepository.php
Normal file
60
src/Repository/EmployeeRepository.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\Employee;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<Employee>
|
||||||
|
*/
|
||||||
|
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()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
43
src/Repository/MissionCategoryRepository.php
Normal file
43
src/Repository/MissionCategoryRepository.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\MissionCategory;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<MissionCategory>
|
||||||
|
*/
|
||||||
|
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()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user