diff --git a/src/Controller/AffectationController.php b/src/Controller/AffectationController.php index 4c2adb7..db70093 100644 --- a/src/Controller/AffectationController.php +++ b/src/Controller/AffectationController.php @@ -11,6 +11,8 @@ class AffectationController extends AbstractController #[Route('/affectation', name: 'app_affectation')] public function index(): Response { + + return $this->render('affectation/index.html.twig', [ 'controller_name' => 'AffectationController', ]); diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php index 82fcfaa..e93d322 100644 --- a/src/Controller/DashboardController.php +++ b/src/Controller/DashboardController.php @@ -12,7 +12,6 @@ class DashboardController extends AbstractController #[Route('', name: '_index')] public function index(): Response { - - return $this->render('dashboard/dashboard.html.twig'); + return $this->render('dashboard/index.html.twig'); } } diff --git a/src/Entity/Assignment.php b/src/Entity/Assignment.php index ad69428..a1718be 100644 --- a/src/Entity/Assignment.php +++ b/src/Entity/Assignment.php @@ -4,17 +4,20 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; -#[ORM\Table(name: 'Assignment')] +#[ORM\Entity] +#[ORM\UniqueConstraint( + columns: ['employee', 'ride'] +)] class Assignment { #[ORM\Id] - #[ORM\OneToMany(targetEntity: Employee::class, mappedBy: 'assignments')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Employee::class, inversedBy: 'assignments')] + #[ORM\Column(type: 'integer')] private ?Employee $employee = null; #[ORM\Id] - #[ORM\OneToMany(targetEntity: Ride::class, mappedBy: 'assignments')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Ride::class, inversedBy: 'assignments')] + #[ORM\Column(type: 'integer')] private ?Ride $ride = null; #[ORM\Column] diff --git a/src/Entity/Category.php b/src/Entity/Category.php index d143883..1909e55 100644 --- a/src/Entity/Category.php +++ b/src/Entity/Category.php @@ -6,7 +6,7 @@ namespace App\Entity; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; - +#[ORM\Entity] class Category { #[ORM\Id] @@ -17,8 +17,8 @@ class Category #[ORM\Column(length: 30)] private ?string $label = null; - #[ORM\ManyToOne(targetEntity: MissionCategory::class, inversedBy: 'category')] - private Collection $missionCategory; + #[ORM\OneToMany(targetEntity: MissionCategory::class, mappedBy: 'category')] + private Collection $missionCategories; public function getId(): ?int { @@ -54,18 +54,31 @@ class Category $this->mission = $mission; } - public function getMissionCategory(): Collection + public function getMissionCategorie(): Collection { - return $this->missionCategory; + return $this->missionCategories; } - public function setMissionCategory(Collection $missionCategory): void + public function addMissionCategory(MissionCategory $missionCategory): static { - $this->missionCategory = $missionCategory; + if(!$this->missionCategories->contains($missionCategory)) { + $this->missionCategories->add($missionCategory); + $missionCategory->setCategory($this); + } + + return $this; } + public function removeMissionCategory(MissionCategory $missionCategory): static + { + if($this->missionCategories->removeElement($missionCategory)) { + if($missionCategory->getCategory() === $this) { + $missionCategory->setCategory(null); + } + } - + return $this; + } } diff --git a/src/Entity/Employee.php b/src/Entity/Employee.php index 6b602ba..a045a81 100644 --- a/src/Entity/Employee.php +++ b/src/Entity/Employee.php @@ -9,7 +9,7 @@ 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)] +#[ORM\Entity] #[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])] class Employee implements UserInterface, PasswordAuthenticatedUserInterface { @@ -33,8 +33,9 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column] private array $roles = []; - #[ORM\ManyToOne(targetEntity: EmployeeSkill::class, inversedBy: 'employee')] - private Collection $employeeskills; + #[ORM\OneToMany(targetEntity: EmployeeSkill::class, mappedBy: 'employee')] + #[ORM\JoinColumn(referencedColumnName: 'employee')] + private Collection $employeeSkills; #[ORM\ManyToOne(targetEntity: Mission::class, inversedBy: 'employee')] private Collection $missions; @@ -42,40 +43,58 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\ManyToOne(targetEntity: Incident::class, inversedBy: 'employee')] private Collection $incidents; - #[ORM\ManyToOne(targetEntity: Assignment::class, inversedBy: 'employee')] + #[ORM\OneToMany(targetEntity: Assignment::class, mappedBy: 'employee')] + #[ORM\JoinColumn(referencedColumnName: 'employee')] private Collection $assignments; - #[ORM\ManyToOne(targetEntity: Representation::class, inversedBy: 'employee')] + #[ORM\OneToMany(targetEntity: Representation::class, mappedBy: 'employee')] + #[ORM\JoinColumn(referencedColumnName: 'employee')] private Collection $representations; - public function getEmployeeskills(): Collection + public function getEmployeeSkills(): Collection { - return $this->employeeskills; + return $this->employeeSkills; } - public function setEmployeeskills(Collection $employeeskills): void + public function addEmployeeSkill(EmployeeSkill $employeeSkill): static { - $this->employeeskills = $employeeskills; + if(!$this->employeeSkills->contains($employeeSkill)) { + $this->employeeSkills->add($employeeSkill); + $employeeSkill->setEmployee($this); + } + + return $this; } - public function getEmployeemissions(): Collection + public function removeEmployeeSkill(EmployeeSkill $employeeSkill): static { - return $this->employeemissions; + if($this->employeeSkills->removeElement($employeeSkill)) { + if($employeeSkill->getEmployee() === $this) { + $employeeSkill->setEmployee(null); + } + } + + return $this; } - public function setEmployeemissions(Collection $employeemissions): void + public function getEmployeeMissions(): Collection { - $this->employeemissions = $employeemissions; + return $this->employeeMissions; } - public function getEmployeeincidents(): Collection + public function setEmployeeMissions(Collection $employeeMissions): void { - return $this->employeeincidents; + $this->employeeMissions = $employeeMissions; } - public function setEmployeeincidents(Collection $employeeincidents): void + public function getEmployeeIncidents(): Collection { - $this->employeeincidents = $employeeincidents; + return $this->employeeIncidents; + } + + public function setEmployeeIncidents(Collection $employeeIncidents): void + { + $this->employeeIncidents = $employeeIncidents; } public function getAssignments(): Collection @@ -83,9 +102,25 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface return $this->assignments; } - public function setAssignments(Collection $assignments): void + public function addAssigment(Assignment $assignment): static { - $this->assignments = $assignments; + if(!$this->assignments->contains($assignment)) { + $this->assignments->add($assignment); + $assignment->setEmployee($this); + } + + return $this; + } + + public function removeAssigment(Assignment $assignment): static + { + if($this->assignments->removeElement($assignment)) { + if($assignment->getEmployee() === $this) { + $assignment->setEmployee(null); + } + } + + return $this; } public function getRepresentations(): Collection @@ -93,9 +128,25 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface return $this->representations; } - public function setRepresentations(Collection $representations): void + public function addRepresentation(Representation $representation): static { - $this->representations = $representations; + if(!$this->representations->contains($representation)) { + $this->representations->add($representation); + $representation->setEmployee($this); + } + + return $this; + } + + public function removeRepresentation(Representation $representation): static + { + if($this->representations->removeElement($representation)) { + if($representation->getEmployee() === $this) { + $representation->setEmployee(null); + } + } + + return $this; } public function getId(): ?int diff --git a/src/Entity/EmployeeSkill.php b/src/Entity/EmployeeSkill.php index efbaae9..c86ddbb 100644 --- a/src/Entity/EmployeeSkill.php +++ b/src/Entity/EmployeeSkill.php @@ -4,17 +4,20 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; -#[ORM\Table(name: 'EmployeeSkill')] +#[ORM\Entity] +#[ORM\UniqueConstraint( + columns: ['employee', 'skill'] +)] class EmployeeSkill { #[ORM\Id] - #[ORM\OneToMany(targetEntity: Employee::class, mappedBy: 'EmployeeSkills')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Employee::class, inversedBy: 'employeeSkills')] + #[ORM\Column(type: 'integer')] private ?Employee $employee = null; #[ORM\Id] - #[ORM\OneToMany(targetEntity: Skill::class, mappedBy: 'EmployeeSkills')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Skill::class, inversedBy: 'employeeSkills')] + #[ORM\Column(type: 'integer')] private ?Skill $skill = null; public function getSkill(): ?Skill diff --git a/src/Entity/Incident.php b/src/Entity/Incident.php index d311bd8..46cfc4a 100644 --- a/src/Entity/Incident.php +++ b/src/Entity/Incident.php @@ -5,6 +5,7 @@ namespace App\Entity; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +#[ORM\Entity] class Incident { #[ORM\Id] diff --git a/src/Entity/IncidentType.php b/src/Entity/IncidentType.php index 5499ab3..be9d6ed 100644 --- a/src/Entity/IncidentType.php +++ b/src/Entity/IncidentType.php @@ -6,7 +6,7 @@ namespace App\Entity; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; - +#[ORM\Entity] class IncidentType { #[ORM\Id] diff --git a/src/Entity/Mission.php b/src/Entity/Mission.php index 719703c..bff89c8 100644 --- a/src/Entity/Mission.php +++ b/src/Entity/Mission.php @@ -6,7 +6,7 @@ namespace App\Entity; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; - +#[ORM\Entity] class Mission { #[ORM\Id] @@ -17,26 +17,44 @@ class Mission #[ORM\Column(length: 30)] private ?string $label = null; - #[ORM\ManyToOne(targetEntity: Requirement::class, inversedBy: 'mission')] + #[ORM\OneToMany(targetEntity: Requirement::class, mappedBy: 'mission')] + #[ORM\JoinColumn(referencedColumnName: 'mission')] private Collection $requirements; #[ORM\OneToMany(targetEntity: Employee::class, mappedBy: 'mission')] - private ?employee $employee = null; + private ?Employee $employee = null; #[ORM\OneToMany(targetEntity: Ride::class, mappedBy: 'mission')] private ?Ride $ride; - #[ORM\ManyToOne(targetEntity: MissionCategory::class, inversedBy: 'mission')] - private Collection $missionCategory; + #[ORM\OneToMany(targetEntity: MissionCategory::class, mappedBy: 'mission')] + #[ORM\JoinColumn(referencedColumnName: 'mission')] + private Collection $missionCategories; public function getRequirements(): Collection { return $this->requirements; } - public function setRequirements(Collection $requirements): void + public function addRequirement(Requirement $requirement): static { - $this->requirements = $requirements; + if(!$this->requirements->contains($requirement)) { + $this->requirements->add($requirement); + $requirement->setMission($this); + } + + return $this; + } + + public function removeRequirement(Requirement $requirement): static + { + if($this->requirements->removeElement($requirement)) { + if($requirement->getMission() === $this) { + $requirement->setMission(null); + } + } + + return $this; } public function getEmployeemissions(): Collection @@ -104,18 +122,31 @@ class Mission $this->ride = $ride; } - public function getMissionCategory(): Collection + public function getMissionCategorie(): Collection { - return $this->missionCategory; + return $this->missionCategories; } - public function setMissionCategory(Collection $missionCategory): void + public function addMissionCategory(MissionCategory $missionCategory): static { - $this->missionCategory = $missionCategory; + if(!$this->missionCategories->contains($missionCategory)) { + $this->missionCategories->add($missionCategory); + $missionCategory->setMission($this); + } + + return $this; } + public function removeMissionCategory(MissionCategory $missionCategory): static + { + if($this->missionCategories->removeElement($missionCategory)) { + if($missionCategory->getMission() === $this) { + $missionCategory->setMission(null); + } + } - + return $this; + } } diff --git a/src/Entity/MissionCategory.php b/src/Entity/MissionCategory.php index 862d5a8..ea5680d 100644 --- a/src/Entity/MissionCategory.php +++ b/src/Entity/MissionCategory.php @@ -5,17 +5,18 @@ namespace App\Entity; use App\Repository\MissionCategoryRepository; use Doctrine\ORM\Mapping as ORM; -#[ORM\Entity(repositoryClass: MissionCategoryRepository::class)] +#[ORM\Entity] +#[ORM\UniqueConstraint(columns: ['mission', 'category'])] class MissionCategory { #[ORM\Id] - #[ORM\OneToMany(targetEntity: Mission::class, mappedBy: 'MissionCategory')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Mission::class, inversedBy: 'missionCategories')] + #[ORM\Column(type: 'integer')] private ?Mission $mission = null; #[ORM\Id] - #[ORM\OneToMany(targetEntity: Category::class, mappedBy: 'MissionCategory')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Category::class, inversedBy: 'missionCategories')] + #[ORM\Column(type: 'integer')] private ?Category $category = null; public function getMission(): ?Mission diff --git a/src/Entity/Representation.php b/src/Entity/Representation.php index 71a49be..a7d4670 100644 --- a/src/Entity/Representation.php +++ b/src/Entity/Representation.php @@ -4,17 +4,20 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; -#[ORM\Table(name: 'Representation')] +#[ORM\Entity] +#[ORM\UniqueConstraint( + columns: ['employee', 'ride'] +)] class Representation { #[ORM\Id] - #[ORM\OneToMany(targetEntity: Employee::class, mappedBy: 'representations')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Employee::class, inversedBy: 'representations')] + #[ORM\Column(type: 'integer')] private ?Employee $employee = null; #[ORM\Id] - #[ORM\OneToMany(targetEntity: Ride::class, mappedBy: 'representations')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Ride::class, inversedBy: 'representations')] + #[ORM\Column(type: 'integer')] private ?Ride $ride = null; #[ORM\Column] diff --git a/src/Entity/Requirement.php b/src/Entity/Requirement.php index 5009c0b..1bf1df7 100644 --- a/src/Entity/Requirement.php +++ b/src/Entity/Requirement.php @@ -5,17 +5,20 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; -#[ORM\Table(name: 'Requirement')] +#[ORM\Entity] +#[ORM\UniqueConstraint( + columns: ['mission', 'skill'] +)] class Requirement { #[ORM\Id] - #[ORM\OneToMany(targetEntity: Mission::class, mappedBy: 'requirements')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Mission::class, inversedBy: 'requirements')] + #[ORM\Column(type: 'integer')] private ?Mission $mission = null; #[ORM\Id] - #[ORM\OneToMany(targetEntity: Skill::class, mappedBy: 'requirements')] - #[ORM\JoinColumn(nullable: false)] + #[ORM\ManyToOne(targetEntity: Skill::class, inversedBy: 'requirements')] + #[ORM\Column(type: 'integer')] private ?Skill $skill = null; public function getMission(): ?Mission @@ -37,7 +40,4 @@ class Requirement { $this->skill = $skill; } - - - } diff --git a/src/Entity/Ride.php b/src/Entity/Ride.php index 93d2433..0461a95 100644 --- a/src/Entity/Ride.php +++ b/src/Entity/Ride.php @@ -5,7 +5,7 @@ namespace App\Entity; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; - +#[ORM\Entity] class Ride { #[ORM\Id] @@ -19,10 +19,12 @@ class Ride #[ORM\Column] private ?int $count = null; - #[ORM\ManyToOne(targetEntity: Assignment::class, inversedBy: 'ride')] + #[ORM\OneToMany(targetEntity: Assignment::class, mappedBy: 'ride')] + #[ORM\JoinColumn(referencedColumnName: 'ride')] private Collection $assignments; - #[ORM\ManyToOne(targetEntity: Representation::class, inversedBy: 'ride')] + #[ORM\OneToMany(targetEntity: Representation::class, mappedBy: 'ride')] + #[ORM\JoinColumn(referencedColumnName: 'ride')] private Collection $representations; #[ORM\ManyToOne(targetEntity: IncidentType::class, inversedBy: 'ride')] @@ -36,9 +38,25 @@ class Ride return $this->assignments; } - public function setAssignments(Collection $assignments): void + public function addAssigment(Assignment $assignment): static { - $this->assignments = $assignments; + if(!$this->assignments->contains($assignment)) { + $this->assignments->add($assignment); + $assignment->setRide($this); + } + + return $this; + } + + public function removeAssigment(Assignment $assignment): static + { + if($this->assignments->removeElement($assignment)) { + if($assignment->getRide() === $this) { + $assignment->setRide(null); + } + } + + return $this; } public function getRepresentations(): Collection @@ -46,12 +64,26 @@ class Ride return $this->representations; } - public function setRepresentations(Collection $representations): void + public function addRepresentation(Representation $representation): static { - $this->representations = $representations; + if(!$this->representations->contains($representation)) { + $this->representations->add($representation); + $representation->setRide($this); + } + + return $this; } + public function removeRepresentation(Representation $representation): static + { + if($this->representations->removeElement($representation)) { + if($representation->getRide() === $this) { + $representation->setRide(null); + } + } + return $this; + } public function getId(): ?int { diff --git a/src/Entity/Skill.php b/src/Entity/Skill.php index 6561f86..fc02dbc 100644 --- a/src/Entity/Skill.php +++ b/src/Entity/Skill.php @@ -5,7 +5,7 @@ namespace App\Entity; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; - +#[ORM\Entity] class Skill { #[ORM\Id] @@ -16,33 +16,40 @@ class Skill #[ORM\Column(length: 30)] private ?string $label = null; - #[ORM\ManyToOne(targetEntity: Requirement::class, inversedBy: 'skill')] + #[ORM\OneToMany(targetEntity: Requirement::class, mappedBy: 'skill')] + #[ORM\JoinColumn(referencedColumnName: 'skill')] private Collection $requirements; - #[ORM\ManyToOne(targetEntity: EmployeeSkill::class, inversedBy: 'skill')] - private Collection $employeeskills; + #[ORM\OneToMany(targetEntity: EmployeeSkill::class, mappedBy: 'skill')] + #[ORM\JoinColumn(referencedColumnName: 'skill')] + private Collection $employeeSkills; public function getRequirements(): Collection { return $this->requirements; } - public function setRequirements(Collection $requirements): void + public function addRequirement(Requirement $requirement): static { - $this->requirements = $requirements; + if(!$this->requirements->contains($requirement)) { + $this->requirements->add($requirement); + $requirement->setSkill($this); + } + + return $this; } - public function getEmployeeskills(): Collection + public function removeRequirement(Requirement $requirement): static { - return $this->employeeskills; - } + if($this->requirements->removeElement($requirement)) { + if($requirement->getSkill() === $this) { + $requirement->setSkill(null); + } + } - public function setEmployeeskills(Collection $employeeskills): void - { - $this->employeeskills = $employeeskills; + return $this; } - public function getId(): ?int { return $this->id; @@ -67,5 +74,30 @@ class Skill return $this; } + public function getEmployeeSkills(): Collection + { + return $this->employeeSkills; + } + + public function addEmployeeSkill(EmployeeSkill $employeeSkill): static + { + if(!$this->employeeSkills->contains($employeeSkill)) { + $this->employeeSkills->add($employeeSkill); + $employeeSkill->setSkill($this); + } + + return $this; + } + + public function removeEmployeeSkill(EmployeeSkill $employeeSkill): static + { + if($this->employeeSkills->removeElement($employeeSkill)) { + if($employeeSkill->getSkill() === $this) { + $employeeSkill->setSkill(null); + } + } + + return $this; + } } diff --git a/templates/base.html.twig b/templates/base.html.twig index 3cda30f..4adb8be 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -12,6 +12,11 @@ {% endblock %}
- {% block body %}{% endblock %} +