Add Building entity
This commit is contained in:
parent
c51bbd4d35
commit
f48c80af1c
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,7 @@
|
||||
.ddev
|
||||
*.sql*
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
###> symfony/framework-bundle ###
|
||||
/.env.local
|
||||
|
@ -1,6 +1,6 @@
|
||||
api_platform:
|
||||
title: Hello API Platform
|
||||
version: 1.0.0
|
||||
title: Architetture Roma - API
|
||||
version: beta
|
||||
defaults:
|
||||
stateless: true
|
||||
cache_headers:
|
||||
|
57
src/Entity/Building.php
Normal file
57
src/Entity/Building.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\BuildingRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BuildingRepository::class)]
|
||||
#[ORM\Table(name: 'architettura')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(normalizationContext: ['groups' => 'building:item']),
|
||||
new GetCollection(normalizationContext: ['groups' => 'building:list'])
|
||||
],
|
||||
order: ['name' => 'DESC'],
|
||||
paginationEnabled: false,
|
||||
)]
|
||||
class Building
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['building:list', 'building:item'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, name: 'denominazione')]
|
||||
#[Groups(['building:list', 'building:item'])]
|
||||
private ?string $name = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(int $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
43
src/Repository/BuildingRepository.php
Normal file
43
src/Repository/BuildingRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Building;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Building>
|
||||
*/
|
||||
class BuildingRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Building::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Building[] Returns an array of Building objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('b.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Building
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user