| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [x] Pas de régression - [ ] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: #7 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
93 lines
1.9 KiB
PHP
93 lines
1.9 KiB
PHP
<?php
|
|
|
|
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\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
|
|
#[ORM\Entity]
|
|
#[ORM\Table(name: 'vehicle')]
|
|
#[ApiResource(
|
|
operations: [
|
|
new Get(
|
|
requirements: ['id' => '\d+'],
|
|
normalizationContext: ['groups' => ['vehicle:read']],
|
|
),
|
|
new GetCollection(
|
|
normalizationContext: ['groups' => ['vehicle:read']],
|
|
),
|
|
],
|
|
security: "is_granted('ROLE_USER')",
|
|
)]
|
|
class Vehicle
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
#[Groups(['vehicle:read'])]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 20)]
|
|
#[Groups(['vehicle:read'])]
|
|
private string $plate = '';
|
|
|
|
#[ORM\ManyToOne]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
#[Groups(['vehicle:read'])]
|
|
#[ApiProperty(readableLink: true)]
|
|
private ?Carrier $carrier = null;
|
|
|
|
#[ORM\ManyToOne]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
#[Groups(['vehicle:read'])]
|
|
#[ApiProperty(readableLink: true)]
|
|
private ?Truck $truck = null;
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getPlate(): string
|
|
{
|
|
return $this->plate;
|
|
}
|
|
|
|
public function setPlate(string $plate): self
|
|
{
|
|
$this->plate = $plate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCarrier(): ?Carrier
|
|
{
|
|
return $this->carrier;
|
|
}
|
|
|
|
public function setCarrier(?Carrier $carrier): self
|
|
{
|
|
$this->carrier = $carrier;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTruck(): ?Truck
|
|
{
|
|
return $this->truck;
|
|
}
|
|
|
|
public function setTruck(?Truck $truck): self
|
|
{
|
|
$this->truck = $truck;
|
|
|
|
return $this;
|
|
}
|
|
}
|