<?php
namespace App\Entity;
use App\Repository\AddresseRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: AddresseRepository::class)]
class Addresse
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(nullable: true)]
private ?bool $default_addresse = null;
#[ORM\Column(length: 255)]
private ?string $full_addresse = null;
#[ORM\Column(nullable: true)]
private ?int $code_postale = null;
#[ORM\Column(length: 150, nullable: true)]
private ?string $ville = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $label = null;
// ── extra address-detail fields (restored to match the live DB) ──
#[ORM\Column(length: 20, nullable: true)]
private ?string $floor = null;
#[ORM\Column(length: 30, nullable: true)]
private ?string $apartment = null;
#[ORM\Column(length: 100, nullable: true)]
private ?string $contact_person = null;
#[ORM\Column(length: 30, nullable: true)]
private ?string $contact_phone = null;
// ── geographic hierarchy: Country → Region → City ──
// region is what drives the per-shop delivery-fee lookup at checkout.
#[ORM\ManyToOne(targetEntity: Country::class)]
#[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?Country $country = null;
#[ORM\ManyToOne(targetEntity: Region::class)]
#[ORM\JoinColumn(name: 'region_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?Region $region = null;
#[ORM\ManyToOne(targetEntity: City::class)]
#[ORM\JoinColumn(name: 'city_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
private ?City $city = null;
#[ORM\ManyToOne(inversedBy: 'addresses')]
private ?User $user = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): self
{
return $this;
}
public function isDefaultAddresse(): ?bool
{
return $this->default_addresse;
}
public function setDefaultAddresse(?bool $default_addresse): self
{
$this->default_addresse = $default_addresse;
return $this;
}
public function getFullAddresse(): ?string
{
return $this->full_addresse;
}
public function setFullAddresse(string $full_addresse): self
{
$this->full_addresse = $full_addresse;
return $this;
}
public function getCodePostale(): ?int
{
return $this->code_postale;
}
public function setCodePostale(?int $code_postale): self
{
$this->code_postale = $code_postale;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(string $ville): self
{
$this->ville = $ville;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): self
{
$this->label = $label;
return $this;
}
public function getLabelIcon(): string
{
return match($this->label) {
'Home' => '🏠',
'Work' => '💼',
'Hangout' => '🎯',
default => '📍',
};
}
public function getFloor(): ?string
{
return $this->floor;
}
public function setFloor(?string $floor): self
{
$this->floor = $floor;
return $this;
}
public function getApartment(): ?string
{
return $this->apartment;
}
public function setApartment(?string $apartment): self
{
$this->apartment = $apartment;
return $this;
}
public function getContactPerson(): ?string
{
return $this->contact_person;
}
public function setContactPerson(?string $contact_person): self
{
$this->contact_person = $contact_person;
return $this;
}
public function getContactPhone(): ?string
{
return $this->contact_phone;
}
public function setContactPhone(?string $contact_phone): self
{
$this->contact_phone = $contact_phone;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function getRegion(): ?Region
{
return $this->region;
}
public function setRegion(?Region $region): self
{
$this->region = $region;
return $this;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
}