diff --git a/migrations/Version20260203152543.php b/migrations/Version20260203152543.php new file mode 100644 index 0000000..ac37491 --- /dev/null +++ b/migrations/Version20260203152543.php @@ -0,0 +1,64 @@ +addSql('CREATE TABLE bovin_shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, nb_bovin_send INT NOT NULL, shipment_id INT DEFAULT NULL, bovine_type_id INT DEFAULT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE INDEX IDX_7049F4507BE036FC ON bovin_shipment (shipment_id)'); + $this->addSql('CREATE INDEX IDX_7049F4507899F32E ON bovin_shipment (bovine_type_id)'); + $this->addSql('CREATE TABLE bovine_type_shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, type_label VARCHAR(255) NOT NULL, type_code VARCHAR(255) NOT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE TABLE customer (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, customer_label VARCHAR(255) NOT NULL, customer_code VARCHAR(255) NOT NULL, id_adress_id INT DEFAULT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE INDEX IDX_81398E094B3458B ON customer (id_adress_id)'); + $this->addSql('CREATE TABLE shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, date_receipt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, is_waiting BOOLEAN NOT NULL, licence_plate VARCHAR(255) NOT NULL, test VARCHAR(255) NOT NULL, id_carrier_id INT DEFAULT NULL, id_carrier_1_id INT DEFAULT NULL, id_truck_id INT DEFAULT NULL, licence_plate_1_id INT DEFAULT NULL, id_vehicle_id INT DEFAULT NULL, id_customer_id INT DEFAULT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE INDEX IDX_2CB20DC84554740 ON shipment (id_carrier_id)'); + $this->addSql('CREATE INDEX IDX_2CB20DC817F550F ON shipment (id_carrier_1_id)'); + $this->addSql('CREATE INDEX IDX_2CB20DC964E905B ON shipment (id_truck_id)'); + $this->addSql('CREATE INDEX IDX_2CB20DC3B17D73A ON shipment (licence_plate_1_id)'); + $this->addSql('CREATE INDEX IDX_2CB20DCF1D99706 ON shipment (id_vehicle_id)'); + $this->addSql('CREATE INDEX IDX_2CB20DC8B870E04 ON shipment (id_customer_id)'); + $this->addSql('ALTER TABLE bovin_shipment ADD CONSTRAINT FK_7049F4507BE036FC FOREIGN KEY (shipment_id) REFERENCES shipment (id)'); + $this->addSql('ALTER TABLE bovin_shipment ADD CONSTRAINT FK_7049F4507899F32E FOREIGN KEY (bovine_type_id) REFERENCES bovine_type_shipment (id)'); + $this->addSql('ALTER TABLE customer ADD CONSTRAINT FK_81398E094B3458B FOREIGN KEY (id_adress_id) REFERENCES address (id)'); + $this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC84554740 FOREIGN KEY (id_carrier_id) REFERENCES carrier (id)'); + $this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC817F550F FOREIGN KEY (id_carrier_1_id) REFERENCES vehicle (id)'); + $this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC964E905B FOREIGN KEY (id_truck_id) REFERENCES vehicle (id)'); + $this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC3B17D73A FOREIGN KEY (licence_plate_1_id) REFERENCES carrier (id)'); + $this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DCF1D99706 FOREIGN KEY (id_vehicle_id) REFERENCES vehicle (id)'); + $this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC8B870E04 FOREIGN KEY (id_customer_id) REFERENCES customer (id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE bovin_shipment DROP CONSTRAINT FK_7049F4507BE036FC'); + $this->addSql('ALTER TABLE bovin_shipment DROP CONSTRAINT FK_7049F4507899F32E'); + $this->addSql('ALTER TABLE customer DROP CONSTRAINT FK_81398E094B3458B'); + $this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC84554740'); + $this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC817F550F'); + $this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC964E905B'); + $this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC3B17D73A'); + $this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DCF1D99706'); + $this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC8B870E04'); + $this->addSql('DROP TABLE bovin_shipment'); + $this->addSql('DROP TABLE bovine_type_shipment'); + $this->addSql('DROP TABLE customer'); + $this->addSql('DROP TABLE shipment'); + } +} diff --git a/src/Entity/BovinShipment.php b/src/Entity/BovinShipment.php new file mode 100644 index 0000000..7d261a0 --- /dev/null +++ b/src/Entity/BovinShipment.php @@ -0,0 +1,71 @@ +id; + } + + public function getIdShipment(): ?Shipment + { + return $this->Shipment; + } + + public function setIdShipment(?Shipment $Shipment): static + { + $this->Shipment = $Shipment; + + return $this; + } + + public function getIdType(): ?BovineTypeShipment + { + return $this->BovineType; + } + + public function setIdType(?BovineTypeShipment $BovineType): static + { + $this->BovineType = $BovineType; + + return $this; + } + + public function getNbBovinSend(): ?int + { + return $this->nbBovinSend; + } + + public function setNbBovinSend(int $nbBovinSend): static + { + $this->nbBovinSend = $nbBovinSend; + + return $this; + } +} diff --git a/src/Entity/BovineTypeShipment.php b/src/Entity/BovineTypeShipment.php new file mode 100644 index 0000000..f333fdc --- /dev/null +++ b/src/Entity/BovineTypeShipment.php @@ -0,0 +1,110 @@ + + */ + #[ORM\OneToMany(targetEntity: BovinShipment::class, mappedBy: 'id_type')] + #[Groups(['shipment:read', 'shipment:write', 'bovine-type:read', 'bovine-type:write'])] + private Collection $bovinShipments; + + public function __construct() + { + $this->bovinShipments = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getTypeLabel(): ?string + { + return $this->type_label; + } + + public function setTypeLabel(string $type_label): static + { + $this->type_label = $type_label; + + return $this; + } + + public function getTypeCode(): ?string + { + return $this->type_code; + } + + public function setTypeCode(string $type_code): static + { + $this->type_code = $type_code; + + return $this; + } + + public function getBovineShipment(): ?BovineShipment + { + return $this->bovineShipment; + } + + public function setBovineShipment(?BovineShipment $bovineShipment): static + { + $this->bovineShipment = $bovineShipment; + + return $this; + } + + /** + * @return Collection + */ + public function getBovinShipments(): Collection + { + return $this->bovinShipments; + } + + public function addBovinShipment(BovinShipment $bovinShipment): static + { + if (!$this->bovinShipments->contains($bovinShipment)) { + $this->bovinShipments->add($bovinShipment); + $bovinShipment->setIdType($this); + } + + return $this; + } + + public function removeBovinShipment(BovinShipment $bovinShipment): static + { + if ($this->bovinShipments->removeElement($bovinShipment)) { + // set the owning side to null (unless already changed) + if ($bovinShipment->getIdType() === $this) { + $bovinShipment->setIdType(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php new file mode 100644 index 0000000..03bcbcd --- /dev/null +++ b/src/Entity/Customer.php @@ -0,0 +1,113 @@ + + */ + #[ORM\OneToMany(targetEntity: Shipment::class, mappedBy: 'id_customer')] + private Collection $shipments; + + public function __construct() + { + $this->shipments = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getCustomerLabel(): ?string + { + return $this->customer_label; + } + + public function setCustomerLabel(string $customer_label): static + { + $this->customer_label = $customer_label; + + return $this; + } + + public function getCustomerCode(): ?string + { + return $this->customer_code; + } + + public function setCustomerCode(string $customer_code): static + { + $this->customer_code = $customer_code; + + return $this; + } + + public function getIdAdress(): ?Address + { + return $this->id_adress; + } + + public function setIdAdress(?Address $id_adress): static + { + $this->id_adress = $id_adress; + + return $this; + } + + /** + * @return Collection + */ + public function getShipments(): Collection + { + return $this->shipments; + } + + public function addShipment(Shipment $shipment): static + { + if (!$this->shipments->contains($shipment)) { + $this->shipments->add($shipment); + $shipment->setIdCustomer($this); + } + + return $this; + } + + public function removeShipment(Shipment $shipment): static + { + if ($this->shipments->removeElement($shipment)) { + // set the owning side to null (unless already changed) + if ($shipment->getIdCustomer() === $this) { + $shipment->setIdCustomer(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Shipment.php b/src/Entity/Shipment.php new file mode 100644 index 0000000..74a5299 --- /dev/null +++ b/src/Entity/Shipment.php @@ -0,0 +1,284 @@ + '\d+'], + normalizationContext: ['groups' => ['shipment:read']], + ), + new GetCollection( + normalizationContext: ['groups' => ['shipment:read']], + ), + new Post( + normalizationContext: ['groups' => ['shipment:read']], + denormalizationContext: ['groups' => ['shipment:write']], + ), + new Patch( + requirements: ['id' => '\d+'], + normalizationContext: ['groups' => ['shipment:read']], + denormalizationContext: ['groups' => ['shipment:write']], + ), + // new Get( + // uriTemplate: '/receptions/weigh', + // openapi: new OpenApiOperation( + // summary: 'Fetch the current weight reading', + // description: 'Queries the pont-bascule and returns the weight data.', + // ), + // normalizationContext: ['groups' => ['reception:weigh:read']], + // output: PontBasculeReading::class, + // provider: ReceptionWeighingProvider::class, + // ), + // new Get( + // uriTemplate: '/receptions/{id}/receipt', + // requirements: ['id' => '\d+'], + // openapi: new OpenApiOperation( + // summary: 'Render a reception receipt', + // description: 'Returns a PDF receipt for the reception.', + // ), + // output: false, + // provider: ReceptionReceiptProvider::class, + // ), + ], +)] +class Shipment +{ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column] + #[Groups(['shipment:read'])] + private ?int $id = null; + + #[ORM\Column] + #[Groups(['shipment:read', 'shipment:write'])] + private ?DateTime $date_receipt = null; + + #[ORM\Column] + #[Groups(['shipment:read', 'shipment:write'])] + private ?bool $is_waiting = null; + + #[ORM\Column(length: 255)] + #[Groups(['shipment:read', 'shipment:write'])] + private ?string $licence_plate = null; + + #[ORM\ManyToOne(inversedBy: 'id_carrier_1')] + #[Groups(['shipment:read', 'shipment:write'])] + private ?carrier $id_carrier = null; + + #[ORM\ManyToOne(inversedBy: 'shipments')] + #[Groups(['shipment:read', 'shipment:write'])] + private ?vehicle $id_carrier_1 = null; + + #[ORM\ManyToOne(inversedBy: 'shipments')] + #[Groups(['shipment:read', 'shipment:write'])] + private ?Vehicle $id_truck = null; + + #[ORM\ManyToOne(inversedBy: 'shipments')] + #[Groups(['shipment:read', 'shipment:write'])] + private ?carrier $licence_plate_1 = null; + + #[ORM\ManyToOne(inversedBy: 'shipments')] + #[Groups(['shipment:read', 'shipment:write'])] + private ?Vehicle $id_vehicle = null; + + #[ORM\ManyToOne(inversedBy: 'shipments')] + #[Groups(['shipment:read', 'shipment:write'])] + private ?Customer $id_customer = null; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: BovinShipment::class, mappedBy: 'id_shipment')] + private Collection $id_type; + + #[ORM\Column(length: 255)] + private ?string $test = null; + + public function __construct() + { + $this->id_type = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getDateReceipt(): ?DateTime + { + return $this->date_receipt; + } + + public function setDateReceipt(DateTime $date_receipt): static + { + $this->date_receipt = $date_receipt; + + return $this; + } + + public function isWaiting(): ?bool + { + return $this->is_waiting; + } + + public function setIsWaiting(bool $is_waiting): static + { + $this->is_waiting = $is_waiting; + + return $this; + } + + public function getLicencePlate(): ?string + { + return $this->licence_plate; + } + + public function setLicencePlate(string $licence_plate): static + { + $this->licence_plate = $licence_plate; + + return $this; + } + + public function getIdCarrier(): ?carrier + { + return $this->id_carrier; + } + + public function setIdCarrier(?carrier $id_carrier): static + { + $this->id_carrier = $id_carrier; + + return $this; + } + + public function getIdCarrier1(): ?vehicle + { + return $this->id_carrier_1; + } + + public function setIdCarrier1(?vehicle $id_carrier_1): static + { + $this->id_carrier_1 = $id_carrier_1; + + return $this; + } + + public function getIdTruck(): ?Vehicle + { + return $this->id_truck; + } + + public function setIdTruck(?Vehicle $id_truck): static + { + $this->id_truck = $id_truck; + + return $this; + } + + public function getLicencePlate1(): ?carrier + { + return $this->licence_plate_1; + } + + public function setLicencePlate1(?carrier $licence_plate_1): static + { + $this->licence_plate_1 = $licence_plate_1; + + return $this; + } + + public function getIdVehicle(): ?Vehicle + { + return $this->id_vehicle; + } + + public function setIdVehicle(?Vehicle $id_vehicle): static + { + $this->id_vehicle = $id_vehicle; + + return $this; + } + + public function getIdCustomer(): ?Customer + { + return $this->id_customer; + } + + public function setIdCustomer(?Customer $id_customer): static + { + $this->id_customer = $id_customer; + + return $this; + } + + public function getBovineShipment(): ?BovineShipment + { + return $this->bovineShipment; + } + + public function setBovineShipment(?BovineShipment $bovineShipment): static + { + $this->bovineShipment = $bovineShipment; + + return $this; + } + + /** + * @return Collection + */ + public function getIdType(): Collection + { + return $this->id_type; + } + + public function addIdType(BovinShipment $idType): static + { + if (!$this->id_type->contains($idType)) { + $this->id_type->add($idType); + $idType->setIdShipment($this); + } + + return $this; + } + + public function removeIdType(BovinShipment $idType): static + { + if ($this->id_type->removeElement($idType)) { + // set the owning side to null (unless already changed) + if ($idType->getIdShipment() === $this) { + $idType->setIdShipment(null); + } + } + + return $this; + } + + public function getTest(): ?string + { + return $this->test; + } + + public function setTest(string $test): static + { + $this->test = $test; + + return $this; + } +}