All the code

This commit is contained in:
Marijn Doeve
2024-09-24 22:58:38 +02:00
commit 05f07e9759
49 changed files with 7943 additions and 0 deletions

87
src/Entity/Car.php Normal file
View File

@@ -0,0 +1,87 @@
<?php
namespace App\Entity;
use ApiPlatform\Doctrine\Common\Filter\SearchFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\QueryParameter;
use App\Repository\CarRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CarRepository::class)]
#[ApiResource(
operations: [
new Get(),
new GetCollection(),
]
)]
#[QueryParameter(key: ':property', filter: SearchFilter::class)]
class Car
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
public function __construct(
#[ORM\Column(length: 6, unique: true)]
#[ApiFilter(SearchFilter::class, strategy: 'exact')]
private ?string $registrationPlate = null,
#[ORM\Column(length: 255)]
private ?string $location = null,
#[ORM\ManyToOne(inversedBy: 'cars')]
#[ORM\JoinColumn(nullable: false)]
private ?CarModel $model = null,
) {
}
public function getId(): ?int
{
return $this->id;
}
public function getRegistrationPlate(): ?string
{
return $this->registrationPlate;
}
public function setRegistrationPlate(string $registrationPlate): static
{
$this->registrationPlate = $registrationPlate;
return $this;
}
public function getLocation(): ?string
{
return $this->location;
}
public function setLocation(string $location): static
{
$this->location = $location;
return $this;
}
public function getModel(): ?CarModel
{
return $this->model;
}
public function setModel(?CarModel $model): static
{
$this->model = $model;
return $this;
}
}