Should be done.
This commit is contained in:
parent
08ae5a6676
commit
6763f991dd
@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
/**
|
/**
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
*/
|
*/
|
||||||
final class Version20241206074803 extends AbstractMigration
|
final class Version20241212162704 extends AbstractMigration
|
||||||
{
|
{
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
@ -38,7 +38,8 @@ final class Version20241206074803 extends AbstractMigration
|
|||||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON employee (email)');
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON employee (email)');
|
||||||
$this->addSql('CREATE TABLE employee_skill (employee INT NOT NULL, skill INT NOT NULL, PRIMARY KEY(employee, skill))');
|
$this->addSql('CREATE TABLE employee_skill (employee INT NOT NULL, skill INT NOT NULL, PRIMARY KEY(employee, skill))');
|
||||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_B630E90E5D9F75A15E3DE477 ON employee_skill (employee, skill)');
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_B630E90E5D9F75A15E3DE477 ON employee_skill (employee, skill)');
|
||||||
$this->addSql('CREATE TABLE incident (id INT NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
$this->addSql('CREATE TABLE incident (id INT NOT NULL, ride_id INT DEFAULT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE INDEX IDX_3D03A11A302A8A70 ON incident (ride_id)');
|
||||||
$this->addSql('CREATE TABLE incident_type (id INT NOT NULL, incidents_id INT DEFAULT NULL, label VARCHAR(30) NOT NULL, PRIMARY KEY(id))');
|
$this->addSql('CREATE TABLE incident_type (id INT NOT NULL, incidents_id INT DEFAULT NULL, label VARCHAR(30) NOT NULL, PRIMARY KEY(id))');
|
||||||
$this->addSql('CREATE INDEX IDX_66D2209655955332 ON incident_type (incidents_id)');
|
$this->addSql('CREATE INDEX IDX_66D2209655955332 ON incident_type (incidents_id)');
|
||||||
$this->addSql('CREATE TABLE mission (id INT NOT NULL, label VARCHAR(30) NOT NULL, PRIMARY KEY(id))');
|
$this->addSql('CREATE TABLE mission (id INT NOT NULL, label VARCHAR(30) NOT NULL, PRIMARY KEY(id))');
|
||||||
@ -50,9 +51,7 @@ final class Version20241206074803 extends AbstractMigration
|
|||||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_29D5499E8C03F15C302A8A70AA9E377A ON representation (employee_id, ride_id, date)');
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_29D5499E8C03F15C302A8A70AA9E377A ON representation (employee_id, ride_id, date)');
|
||||||
$this->addSql('CREATE TABLE requirement (mission INT NOT NULL, skill INT NOT NULL, PRIMARY KEY(mission, skill))');
|
$this->addSql('CREATE TABLE requirement (mission INT NOT NULL, skill INT NOT NULL, PRIMARY KEY(mission, skill))');
|
||||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_DB3F55509067F23C5E3DE477 ON requirement (mission, skill)');
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_DB3F55509067F23C5E3DE477 ON requirement (mission, skill)');
|
||||||
$this->addSql('CREATE TABLE ride (id INT NOT NULL, incident_types_id INT DEFAULT NULL, missions_id INT DEFAULT NULL, label VARCHAR(30) NOT NULL, count INT NOT NULL, PRIMARY KEY(id))');
|
$this->addSql('CREATE TABLE ride (id INT NOT NULL, label VARCHAR(30) NOT NULL, count INT NOT NULL, PRIMARY KEY(id))');
|
||||||
$this->addSql('CREATE INDEX IDX_9B3D7CD076775724 ON ride (incident_types_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_9B3D7CD017C042CF ON ride (missions_id)');
|
|
||||||
$this->addSql('CREATE TABLE skill (id INT NOT NULL, label VARCHAR(30) NOT NULL, PRIMARY KEY(id))');
|
$this->addSql('CREATE TABLE skill (id INT NOT NULL, label VARCHAR(30) NOT NULL, PRIMARY KEY(id))');
|
||||||
$this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
|
$this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
|
||||||
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
|
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
|
||||||
@ -73,11 +72,10 @@ final class Version20241206074803 extends AbstractMigration
|
|||||||
$this->addSql('ALTER TABLE assignment ADD CONSTRAINT FK_30C544BA302A8A70 FOREIGN KEY (ride_id) REFERENCES ride (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE assignment ADD CONSTRAINT FK_30C544BA302A8A70 FOREIGN KEY (ride_id) REFERENCES ride (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A117C042CF FOREIGN KEY (missions_id) REFERENCES mission (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A117C042CF FOREIGN KEY (missions_id) REFERENCES mission (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A155955332 FOREIGN KEY (incidents_id) REFERENCES incident (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE employee ADD CONSTRAINT FK_5D9F75A155955332 FOREIGN KEY (incidents_id) REFERENCES incident (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE incident ADD CONSTRAINT FK_3D03A11A302A8A70 FOREIGN KEY (ride_id) REFERENCES ride (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('ALTER TABLE incident_type ADD CONSTRAINT FK_66D2209655955332 FOREIGN KEY (incidents_id) REFERENCES incident (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE incident_type ADD CONSTRAINT FK_66D2209655955332 FOREIGN KEY (incidents_id) REFERENCES incident (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('ALTER TABLE representation ADD CONSTRAINT FK_29D5499E8C03F15C FOREIGN KEY (employee_id) REFERENCES employee (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE representation ADD CONSTRAINT FK_29D5499E8C03F15C FOREIGN KEY (employee_id) REFERENCES employee (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('ALTER TABLE representation ADD CONSTRAINT FK_29D5499E302A8A70 FOREIGN KEY (ride_id) REFERENCES ride (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
$this->addSql('ALTER TABLE representation ADD CONSTRAINT FK_29D5499E302A8A70 FOREIGN KEY (ride_id) REFERENCES ride (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
$this->addSql('ALTER TABLE ride ADD CONSTRAINT FK_9B3D7CD076775724 FOREIGN KEY (incident_types_id) REFERENCES incident_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
||||||
$this->addSql('ALTER TABLE ride ADD CONSTRAINT FK_9B3D7CD017C042CF FOREIGN KEY (missions_id) REFERENCES mission (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
public function down(Schema $schema): void
|
||||||
@ -95,11 +93,10 @@ final class Version20241206074803 extends AbstractMigration
|
|||||||
$this->addSql('ALTER TABLE assignment DROP CONSTRAINT FK_30C544BA302A8A70');
|
$this->addSql('ALTER TABLE assignment DROP CONSTRAINT FK_30C544BA302A8A70');
|
||||||
$this->addSql('ALTER TABLE employee DROP CONSTRAINT FK_5D9F75A117C042CF');
|
$this->addSql('ALTER TABLE employee DROP CONSTRAINT FK_5D9F75A117C042CF');
|
||||||
$this->addSql('ALTER TABLE employee DROP CONSTRAINT FK_5D9F75A155955332');
|
$this->addSql('ALTER TABLE employee DROP CONSTRAINT FK_5D9F75A155955332');
|
||||||
|
$this->addSql('ALTER TABLE incident DROP CONSTRAINT FK_3D03A11A302A8A70');
|
||||||
$this->addSql('ALTER TABLE incident_type DROP CONSTRAINT FK_66D2209655955332');
|
$this->addSql('ALTER TABLE incident_type DROP CONSTRAINT FK_66D2209655955332');
|
||||||
$this->addSql('ALTER TABLE representation DROP CONSTRAINT FK_29D5499E8C03F15C');
|
$this->addSql('ALTER TABLE representation DROP CONSTRAINT FK_29D5499E8C03F15C');
|
||||||
$this->addSql('ALTER TABLE representation DROP CONSTRAINT FK_29D5499E302A8A70');
|
$this->addSql('ALTER TABLE representation DROP CONSTRAINT FK_29D5499E302A8A70');
|
||||||
$this->addSql('ALTER TABLE ride DROP CONSTRAINT FK_9B3D7CD076775724');
|
|
||||||
$this->addSql('ALTER TABLE ride DROP CONSTRAINT FK_9B3D7CD017C042CF');
|
|
||||||
$this->addSql('DROP TABLE assignment');
|
$this->addSql('DROP TABLE assignment');
|
||||||
$this->addSql('DROP TABLE category');
|
$this->addSql('DROP TABLE category');
|
||||||
$this->addSql('DROP TABLE employee');
|
$this->addSql('DROP TABLE employee');
|
@ -7,6 +7,7 @@ use App\Entity\Representation;
|
|||||||
use App\Entity\Ride;
|
use App\Entity\Ride;
|
||||||
use App\Form\RepresentationType;
|
use App\Form\RepresentationType;
|
||||||
use App\Repository\RepresentationRepository;
|
use App\Repository\RepresentationRepository;
|
||||||
|
use App\Repository\RideRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -16,6 +17,12 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||||||
#[Route('/representation', name: 'representation')]
|
#[Route('/representation', name: 'representation')]
|
||||||
final class RepresentationController extends AbstractController
|
final class RepresentationController extends AbstractController
|
||||||
{
|
{
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
// TODO: Implement __toString() method.
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
#[Route(name: '_index', methods: ['GET'])]
|
#[Route(name: '_index', methods: ['GET'])]
|
||||||
public function index(RepresentationRepository $representationRepository): Response
|
public function index(RepresentationRepository $representationRepository): Response
|
||||||
{
|
{
|
||||||
@ -25,23 +32,20 @@ final class RepresentationController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/new', name: '_new', methods: ['GET', 'POST'])]
|
#[Route('/new', name: '_new', methods: ['GET', 'POST'])]
|
||||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
public function new(Request $request, EntityManagerInterface $entityManager, RideRepository $rideRepository): Response
|
||||||
{
|
{
|
||||||
$representation = new Representation();
|
$representation = new Representation();
|
||||||
$form = $this->createForm(RepresentationType::class, $representation);
|
$form = $this->createForm(RepresentationType::class, $representation);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
// $employee = $entityManager->getRepository(Employee::class)->findOneBy(['email' => $this->getUser()->getEmail()]);
|
|
||||||
// $ride = $entityManager->getRepository(Ride::class)->findOneBy(['id' => $form->get('ride')->getData()]);
|
|
||||||
|
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
// $representation->setEmployee($employee);
|
$ride = $rideRepository->find($representation->getRide());
|
||||||
// $representation->setRide($ride);
|
$newCount = $ride->getCount() + $representation->getCount();
|
||||||
// dd($representation);
|
$ride->setCount($newCount);
|
||||||
|
|
||||||
$entityManager->persist($representation);
|
$entityManager->persist($representation);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
//
|
||||||
return $this->redirectToRoute('representation_index', [], Response::HTTP_SEE_OTHER);
|
return $this->redirectToRoute('representation_index', [], Response::HTTP_SEE_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class Incident
|
|||||||
#[ORM\OneToMany(targetEntity: IncidentType::class, mappedBy: 'incident')]
|
#[ORM\OneToMany(targetEntity: IncidentType::class, mappedBy: 'incident')]
|
||||||
private ?IncidentType $incidentType;
|
private ?IncidentType $incidentType;
|
||||||
|
|
||||||
#[ORM\OneToMany(targetEntity: Ride::class, mappedBy: 'incident')]
|
#[ORM\ManyToOne(targetEntity: Ride::class, inversedBy: 'incidents')]
|
||||||
private ?Ride $ride;
|
private ?Ride $ride;
|
||||||
|
|
||||||
public function getEmployeeincidents(): Collection
|
public function getEmployeeincidents(): Collection
|
||||||
|
@ -25,9 +25,6 @@ class Mission
|
|||||||
#[ORM\OneToMany(targetEntity: Employee::class, mappedBy: 'mission')]
|
#[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\OneToMany(targetEntity: MissionCategory::class, mappedBy: 'mission')]
|
#[ORM\OneToMany(targetEntity: MissionCategory::class, mappedBy: 'mission')]
|
||||||
#[ORM\JoinColumn(referencedColumnName: 'mission')]
|
#[ORM\JoinColumn(referencedColumnName: 'mission')]
|
||||||
private Collection $missionCategories;
|
private Collection $missionCategories;
|
||||||
|
@ -26,10 +26,10 @@ class Ride
|
|||||||
#[ORM\OneToMany(targetEntity: Representation::class, mappedBy: 'ride')]
|
#[ORM\OneToMany(targetEntity: Representation::class, mappedBy: 'ride')]
|
||||||
private Collection $representations;
|
private Collection $representations;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: IncidentType::class, inversedBy: 'ride')]
|
#[ORM\OneToMany(targetEntity: Incident::class, mappedBy: 'ride')]
|
||||||
private Collection $incidentTypes;
|
private Collection $incidents;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: Mission::class, inversedBy: 'ride')]
|
#[ORM\OneToMany(targetEntity: Mission::class, mappedBy: 'ride')]
|
||||||
private Collection $missions;
|
private Collection $missions;
|
||||||
|
|
||||||
public function getAssignments(): Collection
|
public function getAssignments(): Collection
|
||||||
@ -60,7 +60,7 @@ class Ride
|
|||||||
|
|
||||||
public function getRepresentations(): Collection
|
public function getRepresentations(): Collection
|
||||||
{
|
{
|
||||||
return $this->representations;
|
return $this->incidents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRepresentation(Representation $representation): static
|
public function addRepresentation(Representation $representation): static
|
||||||
@ -120,16 +120,6 @@ class Ride
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIncidentTypes(): Collection
|
|
||||||
{
|
|
||||||
return $this->incidentTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setIncidentTypes(Collection $incidentTypes): void
|
|
||||||
{
|
|
||||||
$this->incidentTypes = $incidentTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMissions(): Collection
|
public function getMissions(): Collection
|
||||||
{
|
{
|
||||||
return $this->missions;
|
return $this->missions;
|
||||||
@ -140,6 +130,16 @@ class Ride
|
|||||||
$this->missions = $missions;
|
$this->missions = $missions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIncidents(): Collection
|
||||||
|
{
|
||||||
|
return $this->incidents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIncidents(Collection $incidents): void
|
||||||
|
{
|
||||||
|
$this->incidents = $incidents;
|
||||||
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return $this->label;
|
return $this->label;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\Entity\Incident;
|
||||||
use App\Entity\IncidentType;
|
use App\Entity\IncidentType;
|
||||||
use App\Entity\Mission;
|
use App\Entity\Mission;
|
||||||
use App\Entity\Ride;
|
use App\Entity\Ride;
|
||||||
@ -17,8 +18,8 @@ class RideType extends AbstractType
|
|||||||
$builder
|
$builder
|
||||||
->add('label')
|
->add('label')
|
||||||
->add('count')
|
->add('count')
|
||||||
->add('incidentTypes', EntityType::class, [
|
->add('incidents', EntityType::class, [
|
||||||
'class' => IncidentType::class,
|
'class' => Incident::class,
|
||||||
'choice_label' => 'id',
|
'choice_label' => 'id',
|
||||||
])
|
])
|
||||||
->add('missions', EntityType::class, [
|
->add('missions', EntityType::class, [
|
||||||
|
Loading…
Reference in New Issue
Block a user