feat : Expedition dev back-end WIP

This commit is contained in:
2026-02-04 16:58:55 +01:00
parent e249d44e78
commit ba4375f609
13 changed files with 396 additions and 586 deletions

View File

@@ -35,27 +35,27 @@ class Address
private ?int $id = null;
#[ORM\Column(length: 120)]
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
private string $label = '';
#[ORM\Column(length: 180)]
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
private string $street = '';
#[ORM\Column(name: 'street2', length: 180, nullable: true)]
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
private ?string $street2 = null;
#[ORM\Column(name: 'postal_code', length: 20)]
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
private string $postalCode = '';
#[ORM\Column(length: 120)]
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
private string $city = '';
#[ORM\Column(name: 'country_code', length: 2)]
#[Groups(['address:read', 'supplier:read'])]
#[Groups(['address:read', 'supplier:read', 'customer:read'])]
private string $countryCode = '';
/**
@@ -64,16 +64,9 @@ class Address
#[ORM\ManyToMany(targetEntity: Supplier::class, mappedBy: 'addresses')]
private Collection $suppliers;
/**
* @var Collection<int, Customer>
*/
#[ORM\OneToMany(targetEntity: Customer::class, mappedBy: 'id_adress')]
private Collection $customers;
public function __construct()
{
$this->suppliers = new ArrayCollection();
$this->customers = new ArrayCollection();
}
public function getId(): ?int
@@ -172,34 +165,4 @@ class Address
{
return $this->suppliers;
}
/**
* @return Collection<int, Customer>
*/
public function getCustomers(): Collection
{
return $this->customers;
}
public function addCustomer(Customer $customer): static
{
if (!$this->customers->contains($customer)) {
$this->customers->add($customer);
$customer->setIdAdress($this);
}
return $this;
}
public function removeCustomer(Customer $customer): static
{
if ($this->customers->removeElement($customer)) {
// set the owning side to null (unless already changed)
if ($customer->getIdAdress() === $this) {
$customer->setIdAdress(null);
}
}
return $this;
}
}

View File

@@ -7,8 +7,6 @@ namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
@@ -23,15 +21,7 @@ use Symfony\Component\Serializer\Attribute\Groups;
new GetCollection(
normalizationContext: ['groups' => ['bovin-shipment:read']],
),
new Post(
normalizationContext: ['groups' => ['bovin-shipment:read']],
denormalizationContext: ['groups' => ['bovin-shipment:write']],
),
new Patch(
requirements: ['id' => '\d+'],
normalizationContext: ['groups' => ['bovin-shipment:read']],
denormalizationContext: ['groups' => ['bovin-shipment:write']],
),
// new Get(
// uriTemplate: '/receptions/weigh',
// openapi: new OpenApiOperation(
@@ -62,16 +52,16 @@ class BovinShipment
#[Groups(['shipment:read', 'bovine-shipment:read'])]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'shipment')]
#[Groups(['shipment:read', 'shipment:write', 'bovine-shipment:read', 'bovine-shipment:write'])]
private ?Shipment $Shipment = null;
#[ORM\ManyToOne(inversedBy: 'shipment_types')]
#[Groups(['bovine-shipment:read'])]
private ?Shipment $shipment = null;
#[ORM\ManyToOne(inversedBy: 'bovinShipments')]
#[Groups(['shipment:read', 'shipment:write', 'bovine-shipment:read', 'bovine-shipment:write'])]
private ?BovineTypeShipment $BovineType = null;
#[ORM\ManyToOne]
#[Groups(['shipment:read', 'bovine-shipment:read'])]
private ?ShipmentType $shipmentType = null;
#[ORM\Column]
#[Groups(['shipment:read', 'shipment:write', 'bovine-shipment:read', 'bovine-shipment:write'])]
#[Groups(['shipment:read', 'bovine-shipment:read'])]
private ?int $nbBovinSend = null;
public function getId(): ?int
@@ -79,28 +69,24 @@ class BovinShipment
return $this->id;
}
public function getIdShipment(): ?Shipment
public function getShipment(): ?Shipment
{
return $this->Shipment;
return $this->shipment;
}
public function setIdShipment(?Shipment $Shipment): static
public function setShipment(?Shipment $shipment): void
{
$this->Shipment = $Shipment;
return $this;
$this->shipment = $shipment;
}
public function getIdType(): ?BovineTypeShipment
public function getShipmentType(): ?ShipmentType
{
return $this->BovineType;
return $this->shipmentType;
}
public function setIdType(?BovineTypeShipment $BovineType): static
public function setShipmentType(?ShipmentType $shipmentType): void
{
$this->BovineType = $BovineType;
return $this;
$this->shipmentType = $shipmentType;
}
public function getNbBovinSend(): ?int
@@ -108,10 +94,8 @@ class BovinShipment
return $this->nbBovinSend;
}
public function setNbBovinSend(int $nbBovinSend): static
public function setNbBovinSend(?int $nbBovinSend): void
{
$this->nbBovinSend = $nbBovinSend;
return $this;
}
}

View File

@@ -1,110 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class BovineTypeShipment
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['shipment:read', 'bovine-type:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write', 'bovine-type:read', 'bovine-type:write'])]
private ?string $type_label = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write', 'bovine-type:read', 'bovine-type:write'])]
private ?string $type_code = null;
/**
* @var Collection<int, BovinShipment>
*/
#[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<int, BovinShipment>
*/
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;
}
}

View File

@@ -7,8 +7,6 @@ namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
@@ -31,35 +29,17 @@ class Carrier
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
private ?int $id = null;
#[ORM\Column(length: 180)]
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
private string $name = '';
#[ORM\Column(length: 30, nullable: true)]
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
private ?string $code = null;
/**
* @var Collection<int, Shipment>
*/
#[ORM\OneToMany(targetEntity: Shipment::class, mappedBy: 'id_carrier')]
private Collection $id_carrier_1;
/**
* @var Collection<int, Shipment>
*/
#[ORM\OneToMany(targetEntity: Shipment::class, mappedBy: 'licence_plate_1')]
private Collection $shipments;
public function __construct()
{
$this->id_carrier_1 = new ArrayCollection();
$this->shipments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
@@ -88,64 +68,4 @@ class Carrier
return $this;
}
/**
* @return Collection<int, Shipment>
*/
public function getIdCarrier1(): Collection
{
return $this->id_carrier_1;
}
public function addIdCarrier1(Shipment $idCarrier1): static
{
if (!$this->id_carrier_1->contains($idCarrier1)) {
$this->id_carrier_1->add($idCarrier1);
$idCarrier1->setIdCarrier($this);
}
return $this;
}
public function removeIdCarrier1(Shipment $idCarrier1): static
{
if ($this->id_carrier_1->removeElement($idCarrier1)) {
// set the owning side to null (unless already changed)
if ($idCarrier1->getIdCarrier() === $this) {
$idCarrier1->setIdCarrier(null);
}
}
return $this;
}
/**
* @return Collection<int, Shipment>
*/
public function getShipments(): Collection
{
return $this->shipments;
}
public function addShipment(Shipment $shipment): static
{
if (!$this->shipments->contains($shipment)) {
$this->shipments->add($shipment);
$shipment->setLicencePlate1($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->getLicencePlate1() === $this) {
$shipment->setLicencePlate1(null);
}
}
return $this;
}
}

View File

@@ -4,11 +4,29 @@ declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
#[ORM\Entity]
#[ORM\Table(name: 'customer')]
#[ApiResource(
operations: [
new Get(
requirements: ['id' => '\d+'],
normalizationContext: ['groups' => ['customer:read']],
),
new GetCollection(
normalizationContext: ['groups' => ['customer:read']],
),
],
security: "is_granted('ROLE_USER')",
)]
class Customer
{
#[ORM\Id]
@@ -18,26 +36,25 @@ class Customer
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write', 'customer:read', 'customer:write'])]
private ?string $customer_label = null;
#[Groups(['customer:read', 'shipment:read'])]
private ?string $label = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write', 'customer:read', 'customer:write'])]
private ?string $customer_code = null;
#[ORM\ManyToOne(inversedBy: 'customers')]
#[Groups(['shipment:read', 'shipment:write', 'customer:read', 'customer:write'])]
private ?Address $id_adress = null;
#[Groups(['customer:read', 'shipment:read'])]
private ?string $code = null;
/**
* @var Collection<int, Shipment>
* @var Collection<int, Address>
*/
#[ORM\OneToMany(targetEntity: Shipment::class, mappedBy: 'id_customer')]
private Collection $shipments;
#[ORM\ManyToMany(targetEntity: Address::class, inversedBy: 'customers')]
#[ORM\JoinTable(name: 'customer_address')]
#[Groups(['customer:read'])]
#[ApiProperty(readableLink: true)]
private Collection $addresses;
public function __construct()
{
$this->shipments = new ArrayCollection();
$this->addresses = new ArrayCollection();
}
public function getId(): ?int
@@ -45,69 +62,33 @@ class Customer
return $this->id;
}
public function getCustomerLabel(): ?string
public function getLabel(): ?string
{
return $this->customer_label;
return $this->label;
}
public function setCustomerLabel(string $customer_label): static
public function setLabel(?string $label): void
{
$this->customer_label = $customer_label;
return $this;
$this->label = $label;
}
public function getCustomerCode(): ?string
public function getCode(): ?string
{
return $this->customer_code;
return $this->code;
}
public function setCustomerCode(string $customer_code): static
public function setCode(?string $code): void
{
$this->customer_code = $customer_code;
return $this;
$this->code = $code;
}
public function getIdAdress(): ?Address
public function getAddresses(): Collection
{
return $this->id_adress;
return $this->addresses;
}
public function setIdAdress(?Address $id_adress): static
public function setAddresses(Collection $addresses): void
{
$this->id_adress = $id_adress;
return $this;
}
/**
* @return Collection<int, Shipment>
*/
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;
$this->addresses = $addresses;
}
}

View File

@@ -4,16 +4,18 @@ declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use DateTimeImmutable;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Context;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
#[ORM\Entity]
#[ORM\Table(name: 'shipment')]
@@ -36,24 +38,24 @@ use Symfony\Component\Serializer\Attribute\Groups;
denormalizationContext: ['groups' => ['shipment:write']],
),
// new Get(
// uriTemplate: '/receptions/weigh',
// uriTemplate: '/shipments/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']],
// normalizationContext: ['groups' => ['shipment:weigh:read']],
// output: PontBasculeReading::class,
// provider: ReceptionWeighingProvider::class,
// provider: shipmentWeighingProvider::class,
// ),
// new Get(
// uriTemplate: '/receptions/{id}/receipt',
// uriTemplate: '/shipments/{id}/receipt',
// requirements: ['id' => '\d+'],
// openapi: new OpenApiOperation(
// summary: 'Render a reception receipt',
// description: 'Returns a PDF receipt for the reception.',
// summary: 'Render a shipment receipt',
// description: 'Returns a PDF receipt for the shipment.',
// ),
// output: false,
// provider: ReceptionReceiptProvider::class,
// provider: shipmentReceiptProvider::class,
// ),
],
)]
@@ -65,54 +67,53 @@ class Shipment
#[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;
private ?string $licencePlate = null;
#[ORM\ManyToOne(inversedBy: 'id_carrier_1')]
#[Groups(['shipment:read', 'shipment:write'])]
private ?carrier $id_carrier = null;
#[ORM\Column(length: 20, unique: true, nullable: true)]
#[Groups(['shipment:read'])]
private ?string $identificationNumber = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[ORM\Column(options: ['default' => 0])]
#[Groups(['shipment:read', 'shipment:write'])]
private ?vehicle $id_carrier_1 = null;
private int $currentStep = 0;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[ORM\Column]
#[Groups(['shipment:read', 'shipment:write'])]
private ?Vehicle $id_truck = null;
private ?bool $isValid = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[ORM\Column(name: 'shipment_date', type: 'datetime_immutable')]
#[Groups(['shipment:read', 'shipment:write'])]
private ?carrier $licence_plate_1 = null;
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
private ?DateTimeImmutable $shipmentDate = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: true)]
#[Groups(['shipment:read', 'shipment:write'])]
private ?Vehicle $id_vehicle = null;
#[ApiProperty(readableLink: true)]
private ?Carrier $carrier = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: true)]
#[Groups(['shipment:read', 'shipment:write'])]
private ?Customer $id_customer = null;
#[ApiProperty(readableLink: true)]
private ?Truck $truck = null;
#[ORM\ManyToOne]
#[Groups(['shipment:read', 'shipment:write'])]
private ?Customer $customer = null;
/**
* @var Collection<int, BovinShipment>
*/
#[ORM\OneToMany(targetEntity: BovinShipment::class, mappedBy: 'id_shipment')]
private Collection $id_type;
#[ORM\OneToMany(targetEntity: BovinShipment::class, mappedBy: 'shipment')]
#[Groups(['shipment:read', 'shipment:write'])]
private Collection $bovinShipments;
#[ORM\Column(length: 255)]
private ?string $test = null;
public function __construct()
public function __construct(Collection $bovinShipments)
{
$this->id_type = new ArrayCollection();
$this->bovinShipments = $bovinShipments;
}
public function getId(): ?int
@@ -120,165 +121,124 @@ class Shipment
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;
return $this->licencePlate;
}
public function setLicencePlate(string $licence_plate): static
public function setLicencePlate(?string $licencePlate): void
{
$this->licence_plate = $licence_plate;
return $this;
$this->licencePlate = $licencePlate;
}
public function getIdCarrier(): ?carrier
public function getIdentificationNumber(): ?string
{
return $this->id_carrier;
return $this->identificationNumber;
}
public function setIdCarrier(?carrier $id_carrier): static
public function setIdentificationNumber(?string $identificationNumber): void
{
$this->id_carrier = $id_carrier;
return $this;
$this->identificationNumber = $identificationNumber;
}
public function getIdCarrier1(): ?vehicle
public function getCurrentStep(): int
{
return $this->id_carrier_1;
return $this->currentStep;
}
public function setIdCarrier1(?vehicle $id_carrier_1): static
public function setCurrentStep(int $currentStep): void
{
$this->id_carrier_1 = $id_carrier_1;
return $this;
$this->currentStep = $currentStep;
}
public function getIdTruck(): ?Vehicle
public function getIsValid(): ?bool
{
return $this->id_truck;
return $this->isValid;
}
public function setIdTruck(?Vehicle $id_truck): static
public function setIsValid(?bool $isValid): void
{
$this->id_truck = $id_truck;
return $this;
$this->isValid = $isValid;
}
public function getLicencePlate1(): ?carrier
public function getShipmentDate(): ?DateTimeImmutable
{
return $this->licence_plate_1;
return $this->shipmentDate;
}
public function setLicencePlate1(?carrier $licence_plate_1): static
public function setShipmentDate(?DateTimeImmutable $shipmentDate): void
{
$this->licence_plate_1 = $licence_plate_1;
return $this;
$this->shipmentDate = $shipmentDate;
}
public function getIdVehicle(): ?Vehicle
public function getCarrier(): ?Carrier
{
return $this->id_vehicle;
return $this->carrier;
}
public function setIdVehicle(?Vehicle $id_vehicle): static
public function setCarrier(?Carrier $carrier): void
{
$this->id_vehicle = $id_vehicle;
return $this;
$this->carrier = $carrier;
}
public function getIdCustomer(): ?Customer
public function getVehicle(): ?Vehicle
{
return $this->id_customer;
return $this->vehicle;
}
public function setIdCustomer(?Customer $id_customer): static
public function setVehicle(?Vehicle $vehicle): void
{
$this->id_customer = $id_customer;
return $this;
$this->vehicle = $vehicle;
}
public function getBovineShipment(): ?BovineShipment
public function getTruck(): ?Truck
{
return $this->bovineShipment;
return $this->truck;
}
public function setBovineShipment(?BovineShipment $bovineShipment): static
public function setTruck(?Truck $truck): void
{
$this->bovineShipment = $bovineShipment;
return $this;
$this->truck = $truck;
}
/**
* @return Collection<int, BovinShipment>
*/
public function getIdType(): Collection
public function getCustomer(): ?Customer
{
return $this->id_type;
return $this->customer;
}
public function addIdType(BovinShipment $idType): static
public function setCustomer(?Customer $customer): void
{
if (!$this->id_type->contains($idType)) {
$this->id_type->add($idType);
$idType->setIdShipment($this);
$this->customer = $customer;
}
public function getBovinShipments(): Collection
{
return $this->bovinShipments;
}
public function setBovinShipments(Collection $bovinShipments): void
{
$this->bovinShipments = $bovinShipments;
}
public function addPelletBuilding(BovinShipment $bovinShipments): self
{
if (!$this->bovinShipments->contains($bovinShipments)) {
$this->bovinShipments->add($bovinShipments);
$bovinShipments->setReception($this);
}
return $this;
}
public function removeIdType(BovinShipment $idType): static
public function removePelletBuilding(BovinShipment $bovinShipments): self
{
if ($this->id_type->removeElement($idType)) {
// set the owning side to null (unless already changed)
if ($idType->getIdShipment() === $this) {
$idType->setIdShipment(null);
if ($this->bovinShipments->removeElement($bovinShipments)) {
if ($bovinShipments->getReception() === $this) {
$bovinShipments->setReception(null);
}
}
return $this;
}
public function getTest(): ?string
{
return $this->test;
}
public function setTest(string $test): static
{
$this->test = $test;
return $this;
}
}

View File

@@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
#[ORM\Entity]
#[ORM\Table(name: 'shipment_type')]
#[ApiResource(
operations: [
new Get(
requirements: ['id' => '\d+'],
normalizationContext: ['groups' => ['shipment-type:read']],
),
new GetCollection(
normalizationContext: ['groups' => ['shipment-type:read']],
),
],
security: "is_granted('ROLE_USER')",
)]
class ShipmentType
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['shipment-type:read', 'shipment:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment-type:read', 'shipment:read'])]
private ?string $label = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment-type:read', 'shipment:read'])]
private ?string $code = null;
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): static
{
$this->label = $label;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
}

View File

@@ -8,8 +8,6 @@ use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
@@ -51,17 +49,6 @@ class Vehicle
#[ApiProperty(readableLink: true)]
private ?Truck $truck = null;
/**
* @var Collection<int, Shipment>
*/
#[ORM\OneToMany(targetEntity: Shipment::class, mappedBy: 'id_carrier_1')]
private Collection $shipments;
public function __construct()
{
$this->shipments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
@@ -102,34 +89,4 @@ class Vehicle
return $this;
}
/**
* @return Collection<int, Shipment>
*/
public function getShipments(): Collection
{
return $this->shipments;
}
public function addShipment(Shipment $shipment): static
{
if (!$this->shipments->contains($shipment)) {
$this->shipments->add($shipment);
$shipment->setIdCarrier1($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->getIdCarrier1() === $this) {
$shipment->setIdCarrier1(null);
}
}
return $this;
}
}