-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
232 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace App\Entity; | ||
|
||
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; | ||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; | ||
use ApiPlatform\Metadata\ApiFilter; | ||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\Get; | ||
use ApiPlatform\Metadata\GetCollection; | ||
use App\Repository\CodePostaleRepository; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Bridge\Doctrine\Types\UuidType; | ||
use Symfony\Component\Serializer\Attribute\Groups; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
#[ORM\Entity(repositoryClass: CodePostaleRepository::class)] | ||
#[ApiResource( | ||
operations: [ | ||
new Get(), | ||
new GetCollection() | ||
], | ||
normalizationContext: ['groups' => ['code:read']], | ||
)] | ||
#[ApiFilter(SearchFilter::class, properties: ['codePostal' => 'ipartial', 'ville' => 'ipartial'])] | ||
#[ApiFilter(OrderFilter::class, properties: ['codePostal'], arguments: ['orderParameterName' => 'order'])] | ||
class CodePostale | ||
{ | ||
#[ORM\Id] | ||
#[ORM\Column(type: UuidType::NAME, unique: true)] | ||
#[ORM\GeneratedValue(strategy: 'CUSTOM')] | ||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] | ||
#[Groups(['code:read'])] | ||
private ?Uuid $id = null; | ||
|
||
#[ORM\Column(length: 5)] | ||
#[Groups(['code:read'])] | ||
private ?string $codePostal = null; | ||
|
||
#[ORM\Column(length: 255)] | ||
#[Groups(['code:read'])] | ||
private ?string $ville = null; | ||
|
||
#[ORM\ManyToOne] | ||
#[Groups(['code:read'])] | ||
private ?Region $region = null; | ||
|
||
#[ORM\ManyToOne(inversedBy: 'codePostales')] | ||
#[ORM\JoinColumn(nullable: false)] | ||
#[Groups(['code:read'])] | ||
private ?Province $province = null; | ||
|
||
public function getId(): ?string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getCodePostal(): ?string | ||
{ | ||
return $this->codePostal; | ||
} | ||
|
||
public function setCodePostal(string $codePostal): static | ||
{ | ||
$this->codePostal = $codePostal; | ||
|
||
return $this; | ||
} | ||
|
||
public function getVille(): ?string | ||
{ | ||
return $this->ville; | ||
} | ||
|
||
public function setVille(string $ville): static | ||
{ | ||
$this->ville = $ville; | ||
|
||
return $this; | ||
} | ||
|
||
public function getRegion(): ?Region | ||
{ | ||
return $this->region; | ||
} | ||
|
||
public function setRegion(?Region $region): static | ||
{ | ||
$this->region = $region; | ||
|
||
return $this; | ||
} | ||
|
||
public function getProvince(): ?Province | ||
{ | ||
return $this->province; | ||
} | ||
|
||
public function setProvince(?Province $province): static | ||
{ | ||
$this->province = $province; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Repository; | ||
|
||
use App\Entity\CodePostale; | ||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
|
||
/** | ||
* @extends ServiceEntityRepository<CodePostale> | ||
* | ||
* @method CodePostale|null find($id, $lockMode = null, $lockVersion = null) | ||
* @method CodePostale|null findOneBy(array $criteria, array $orderBy = null) | ||
* @method CodePostale[] findAll() | ||
* @method CodePostale[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | ||
*/ | ||
class CodePostaleRepository extends ServiceEntityRepository | ||
{ | ||
public function __construct(ManagerRegistry $registry) | ||
{ | ||
parent::__construct($registry, CodePostale::class); | ||
} | ||
|
||
// /** | ||
// * @return CodePostale[] Returns an array of CodePostale objects | ||
// */ | ||
// public function findByExampleField($value): array | ||
// { | ||
// return $this->createQueryBuilder('c') | ||
// ->andWhere('c.exampleField = :val') | ||
// ->setParameter('val', $value) | ||
// ->orderBy('c.id', 'ASC') | ||
// ->setMaxResults(10) | ||
// ->getQuery() | ||
// ->getResult() | ||
// ; | ||
// } | ||
|
||
// public function findOneBySomeField($value): ?CodePostale | ||
// { | ||
// return $this->createQueryBuilder('c') | ||
// ->andWhere('c.exampleField = :val') | ||
// ->setParameter('val', $value) | ||
// ->getQuery() | ||
// ->getOneOrNullResult() | ||
// ; | ||
// } | ||
} |