<?php
namespace App\Entity;
use App\Repository\AdressRepository;
// Bdd map
use Doctrine\ORM\Mapping as ORM;
// Vérification pour formulaires
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: AdressRepository::class)]
#[ORM\Table(name: 'adresses')]
class Adresse
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
//option "unsigne" que int positifs
#[ORM\Column(type: 'integer', options: ['unsigned' => true])]
private ?int $id = null;
#[Assert\NotBlank(message: 'Le corps de l\'adresse est obligatoire !')]
#[ORM\Column(name: 'corps_adresse', type: 'string', length: 255)]
private ?string $corpsAdresse = null;
#[Assert\NotBlank(message: 'Le code postal de l\'adresse est obligatoire !')]
#[ORM\Column(name: 'code_postal',type: 'string', length: 32)]
private ?string $codePostal = null;
#[Assert\NotBlank(message: 'La ville est obligatoire !')]
#[ORM\Column(name:'ville', type: 'string', length: 120)]
private ?string $ville = null;
#[ORM\Column(length: 50)]
private ?string $pays = null;
// TODO ajouter département?
public function __toString(): string
{
return printf("%s<br>%s %s<br> %s" ,
$this->corpsAdresse, $this->codePostal, strtoupper($this->ville) , strtoupper($this->pays));
}
public function getId(): ?int
{
return $this->id;
}
public function getCorpsAdresse(): ?string
{
return $this->corpsAdresse;
}
public function setCorpsAdresse(string $label): void
{
$this->corpsAdresse = $label;
}
public function getCodePostal(): ?string
{
return $this->codePostal;
}
public function setCodePostal(string $postalCode): void
{
$this->codePostal = $postalCode;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(string $city): void
{
$this->ville = $city;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(User $user): void
{
// set the owning side of the relation if necessary
if ($user->getAdresse() !== $this) {
$user->setAdresse($this);
}
$this->user = $user;
}
public function getPays(): ?string
{
return $this->pays;
}
public function setPays(string $pays): void
{
$this->pays = $pays;
}
}