Fixed RepresentationController.php (Error : Employee would try to be changed into a string)

This commit is contained in:
ASTIER Yann 2024-12-06 08:57:54 +01:00
parent ebc0a27382
commit 97f71e6e23
10 changed files with 46 additions and 296 deletions

View File

@ -23,7 +23,7 @@ doctrine:
prefix: 'App\Entity' prefix: 'App\Entity'
alias: App alias: App
controller_resolver: controller_resolver:
auto_mapping: false auto_mapping: true
when@test: when@test:
doctrine: doctrine:

View File

@ -1,105 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241011084601 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE category_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE employee_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE incident_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE incident_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE mission_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE ride_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE skill_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE assignment (employee INT NOT NULL, ride INT NOT NULL, start_hour TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, end_hour TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(employee, ride))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_30C544BA5D9F75A19B3D7CD0 ON assignment (employee, ride)');
$this->addSql('CREATE TABLE category (id INT NOT NULL, label VARCHAR(30) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE employee (id INT NOT NULL, missions_id INT DEFAULT NULL, incidents_id INT DEFAULT NULL, email VARCHAR(180) NOT NULL, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(30) NOT NULL, password VARCHAR(255) NOT NULL, roles JSON NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_5D9F75A117C042CF ON employee (missions_id)');
$this->addSql('CREATE INDEX IDX_5D9F75A155955332 ON employee (incidents_id)');
$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 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_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 TABLE mission (id INT NOT NULL, label VARCHAR(30) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE mission_category (mission INT NOT NULL, category INT NOT NULL, PRIMARY KEY(mission, category))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_EB018789067F23C64C19C1 ON mission_category (mission, category)');
$this->addSql('CREATE TABLE representation (employee INT NOT NULL, ride INT NOT NULL, count INT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(employee, ride))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_29D5499E5D9F75A19B3D7CD0 ON representation (employee, ride)');
$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 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 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 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_75EA56E0E3BD61CE ON messenger_messages (available_at)');
$this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
$this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$
BEGIN
PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;');
$this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
$this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();');
$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 incident_type ADD CONSTRAINT FK_66D2209655955332 FOREIGN KEY (incidents_id) REFERENCES incident (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
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE category_id_seq CASCADE');
$this->addSql('DROP SEQUENCE employee_id_seq CASCADE');
$this->addSql('DROP SEQUENCE incident_id_seq CASCADE');
$this->addSql('DROP SEQUENCE incident_type_id_seq CASCADE');
$this->addSql('DROP SEQUENCE mission_id_seq CASCADE');
$this->addSql('DROP SEQUENCE ride_id_seq CASCADE');
$this->addSql('DROP SEQUENCE skill_id_seq CASCADE');
$this->addSql('ALTER TABLE employee DROP CONSTRAINT FK_5D9F75A117C042CF');
$this->addSql('ALTER TABLE employee DROP CONSTRAINT FK_5D9F75A155955332');
$this->addSql('ALTER TABLE incident_type DROP CONSTRAINT FK_66D2209655955332');
$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 category');
$this->addSql('DROP TABLE employee');
$this->addSql('DROP TABLE employee_skill');
$this->addSql('DROP TABLE incident');
$this->addSql('DROP TABLE incident_type');
$this->addSql('DROP TABLE mission');
$this->addSql('DROP TABLE mission_category');
$this->addSql('DROP TABLE representation');
$this->addSql('DROP TABLE requirement');
$this->addSql('DROP TABLE ride');
$this->addSql('DROP TABLE skill');
$this->addSql('DROP TABLE messenger_messages');
}
}

View File

@ -1,49 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241017154551 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE category_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE employee_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE incident_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE incident_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE mission_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE ride_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE skill_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON "user" (email)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE category_id_seq CASCADE');
$this->addSql('DROP SEQUENCE employee_id_seq CASCADE');
$this->addSql('DROP SEQUENCE incident_id_seq CASCADE');
$this->addSql('DROP SEQUENCE incident_type_id_seq CASCADE');
$this->addSql('DROP SEQUENCE mission_id_seq CASCADE');
$this->addSql('DROP SEQUENCE ride_id_seq CASCADE');
$this->addSql('DROP SEQUENCE skill_id_seq CASCADE');
$this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');
$this->addSql('DROP TABLE "user"');
}
}

View File

@ -1,49 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241017154952 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE category_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE employee_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE incident_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE incident_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE mission_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE ride_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE skill_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, is_verified BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON "user" (email)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE category_id_seq CASCADE');
$this->addSql('DROP SEQUENCE employee_id_seq CASCADE');
$this->addSql('DROP SEQUENCE incident_id_seq CASCADE');
$this->addSql('DROP SEQUENCE incident_type_id_seq CASCADE');
$this->addSql('DROP SEQUENCE mission_id_seq CASCADE');
$this->addSql('DROP SEQUENCE ride_id_seq CASCADE');
$this->addSql('DROP SEQUENCE skill_id_seq CASCADE');
$this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');
$this->addSql('DROP TABLE "user"');
}
}

View File

@ -1,49 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241114142616 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE category_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE employee_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE incident_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE incident_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE mission_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE ride_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE skill_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, is_verified BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON "user" (email)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP SEQUENCE category_id_seq CASCADE');
$this->addSql('DROP SEQUENCE employee_id_seq CASCADE');
$this->addSql('DROP SEQUENCE incident_id_seq CASCADE');
$this->addSql('DROP SEQUENCE incident_type_id_seq CASCADE');
$this->addSql('DROP SEQUENCE mission_id_seq CASCADE');
$this->addSql('DROP SEQUENCE ride_id_seq CASCADE');
$this->addSql('DROP SEQUENCE skill_id_seq CASCADE');
$this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');
$this->addSql('DROP TABLE "user"');
}
}

View File

@ -16,12 +16,6 @@ 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
{ {
@ -44,11 +38,11 @@ final class RepresentationController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
// $representation->setEmployee($employee); // $representation->setEmployee($employee);
// $representation->setRide($ride); // $representation->setRide($ride);
dd($representation); // dd($representation);
$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);
} }
return $this->render('representation/new.html.twig', [ return $this->render('representation/new.html.twig', [

View File

@ -7,18 +7,16 @@ use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: AssignmentRepository::class)] #[ORM\Entity(repositoryClass: AssignmentRepository::class)]
#[ORM\UniqueConstraint( #[ORM\UniqueConstraint(
columns: ['employee', 'ride'] columns: ['employee_id', 'ride_id']
)] )]
class Assignment class Assignment
{ {
#[ORM\Id] #[ORM\Id]
#[ORM\ManyToOne(targetEntity: Employee::class, inversedBy: 'assignments')] #[ORM\ManyToOne(targetEntity: Employee::class, inversedBy: 'assignments')]
#[ORM\Column(type: 'integer')]
private ?Employee $employee = null; private ?Employee $employee = null;
#[ORM\Id] #[ORM\Id]
#[ORM\ManyToOne(targetEntity: Ride::class, inversedBy: 'assignments')] #[ORM\ManyToOne(targetEntity: Ride::class, inversedBy: 'assignments')]
#[ORM\Column(type: 'integer')]
private ?Ride $ride = null; private ?Ride $ride = null;
#[ORM\Column] #[ORM\Column]

View File

@ -3,6 +3,7 @@
namespace App\Entity; namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use App\Repository\EmployeeRepository; use App\Repository\EmployeeRepository;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -34,23 +35,30 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface
private array $roles = []; private array $roles = [];
#[ORM\OneToMany(targetEntity: EmployeeSkill::class, mappedBy: 'employee')] #[ORM\OneToMany(targetEntity: EmployeeSkill::class, mappedBy: 'employee')]
#[ORM\JoinColumn(referencedColumnName: 'employee')]
private Collection $employeeSkills; private Collection $employeeSkills;
//Changer en ManyToMany et pareil dans mission
#[ORM\ManyToOne(targetEntity: Mission::class, inversedBy: 'employee')] #[ORM\ManyToOne(targetEntity: Mission::class, inversedBy: 'employee')]
private Collection $missions; private Collection $missions;
//Changer en OneToMany et inversement dans incident
#[ORM\ManyToOne(targetEntity: Incident::class, inversedBy: 'employee')] #[ORM\ManyToOne(targetEntity: Incident::class, inversedBy: 'employee')]
private Collection $incidents; private Collection $incidents;
#[ORM\OneToMany(targetEntity: Assignment::class, mappedBy: 'employee')] #[ORM\OneToMany(targetEntity: Assignment::class, mappedBy: 'employee')]
#[ORM\JoinColumn(referencedColumnName: 'employee')]
private Collection $assignments; private Collection $assignments;
#[ORM\OneToMany(targetEntity: Representation::class, mappedBy: 'employee')] #[ORM\OneToMany(targetEntity: Representation::class, mappedBy: 'employee')]
#[ORM\JoinColumn(referencedColumnName: 'employee')]
private Collection $representations; private Collection $representations;
public function __construct()
{
$this->assignments = new ArrayCollection();
$this->representations = new ArrayCollection();
$this->employeeSkills = new ArrayCollection();
}
public function getEmployeeSkills(): Collection public function getEmployeeSkills(): Collection
{ {
return $this->employeeSkills; return $this->employeeSkills;
@ -77,25 +85,25 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface
return $this; return $this;
} }
public function getEmployeeMissions(): Collection // public function getEmployeeMissions(): Collection
{ // {
return $this->employeeMissions; // return $this->employeeMissions;
} // }
//
// public function setEmployeeMissions(Collection $employeeMissions): void
// {
// $this->employeeMissions = $employeeMissions;
// }
public function setEmployeeMissions(Collection $employeeMissions): void // public function getEmployeeIncidents(): Collection
{ // {
$this->employeeMissions = $employeeMissions; // return $this->employeeIncidents;
} // }
//
public function getEmployeeIncidents(): Collection // public function setEmployeeIncidents(Collection $employeeIncidents): void
{ // {
return $this->employeeIncidents; // $this->employeeIncidents = $employeeIncidents;
} // }
public function setEmployeeIncidents(Collection $employeeIncidents): void
{
$this->employeeIncidents = $employeeIncidents;
}
public function getAssignments(): Collection public function getAssignments(): Collection
{ {
@ -239,7 +247,7 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface
return $this; return $this;
} }
public function getMissions(): Collection public function getMissions(): ?Collection
{ {
return $this->missions; return $this->missions;
} }
@ -249,7 +257,7 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface
$this->missions = $missions; $this->missions = $missions;
} }
public function getIncidents(): Collection public function getIncidents(): ?Collection
{ {
return $this->incidents; return $this->incidents;
} }
@ -259,5 +267,8 @@ class Employee implements UserInterface, PasswordAuthenticatedUserInterface
$this->incidents = $incidents; $this->incidents = $incidents;
} }
public function __toString(): string
{
return $this->firstName . ' ' . $this->lastName;
}
} }

View File

@ -7,18 +7,16 @@ use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RepresentationRepository::class)] #[ORM\Entity(repositoryClass: RepresentationRepository::class)]
#[ORM\UniqueConstraint( #[ORM\UniqueConstraint(
columns: ['employee', 'ride'] columns: ['employee_id', 'ride_id', 'date']
)] )]
class Representation class Representation
{ {
#[ORM\Id] #[ORM\Id]
#[ORM\ManyToOne(targetEntity: Employee::class, inversedBy: 'representations')] #[ORM\ManyToOne(targetEntity: Employee::class, inversedBy: 'representations')]
#[ORM\Column(type: 'integer')]
private ?Employee $employee = null; private ?Employee $employee = null;
#[ORM\Id] #[ORM\Id]
#[ORM\ManyToOne(targetEntity: Ride::class, inversedBy: 'representations')] #[ORM\ManyToOne(targetEntity: Ride::class, inversedBy: 'representations')]
#[ORM\Column(type: 'integer')]
private ?Ride $ride = null; private ?Ride $ride = null;
#[ORM\Column] #[ORM\Column]

View File

@ -21,11 +21,9 @@ class Ride
private ?int $count = null; private ?int $count = null;
#[ORM\OneToMany(targetEntity: Assignment::class, mappedBy: 'ride')] #[ORM\OneToMany(targetEntity: Assignment::class, mappedBy: 'ride')]
#[ORM\JoinColumn(referencedColumnName: 'ride')]
private Collection $assignments; private Collection $assignments;
#[ORM\OneToMany(targetEntity: Representation::class, mappedBy: 'ride')] #[ORM\OneToMany(targetEntity: Representation::class, mappedBy: 'ride')]
#[ORM\JoinColumn(referencedColumnName: 'ride')]
private Collection $representations; private Collection $representations;
#[ORM\ManyToOne(targetEntity: IncidentType::class, inversedBy: 'ride')] #[ORM\ManyToOne(targetEntity: IncidentType::class, inversedBy: 'ride')]
@ -142,5 +140,8 @@ class Ride
$this->missions = $missions; $this->missions = $missions;
} }
public function __toString(): string
{
return $this->label;
}
} }