<?php
namespace App\Entity;
use App\Repository\InternauteRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: InternauteRepository::class)]
class Internaute
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $firstname = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $lastname = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $company = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $country = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $address = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $address2 = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $postalCode = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $town = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Email]
#[Assert\Length(max: 255)]
private ?string $email = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255)]
private ?string $phone = null;
#[ORM\OneToMany(mappedBy: 'internaute', targetEntity: ClientOrder::class)]
private Collection $clientOrders;
#[ORM\OneToMany(mappedBy: 'internaute', targetEntity: Mail::class)]
private Collection $mails;
#[ORM\Column(length: 255, nullable: true)]
private ?string $loyalty_card = null;
public function __construct()
{
$this->clientOrders = new ArrayCollection();
$this->mails = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): static
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): static
{
$this->lastname = $lastname;
return $this;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setCompany(?string $company): static
{
$this->company = $company;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): static
{
$this->country = $country;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): static
{
$this->address = $address;
return $this;
}
public function getAddress2(): ?string
{
return $this->address2;
}
public function setAddress2(?string $address2): static
{
$this->address2 = $address2;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postalCode;
}
public function setPostalCode(?string $postalCode): static
{
$this->postalCode = $postalCode;
return $this;
}
public function getTown(): ?string
{
return $this->town;
}
public function setTown(?string $town): static
{
$this->town = $town;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): static
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): static
{
$this->phone = $phone;
return $this;
}
/**
* @return Collection<int, ClientOrder>
*/
public function getClientOrders(): Collection
{
return $this->clientOrders;
}
public function addClientOrder(ClientOrder $clientOrder): static
{
if (!$this->clientOrders->contains($clientOrder)) {
$this->clientOrders->add($clientOrder);
$clientOrder->setInternaute($this);
}
return $this;
}
public function removeClientOrder(ClientOrder $clientOrder): static
{
if ($this->clientOrders->removeElement($clientOrder)) {
// set the owning side to null (unless already changed)
if ($clientOrder->getInternaute() === $this) {
$clientOrder->setInternaute(null);
}
}
return $this;
}
/**
* @return Collection<int, Mail>
*/
public function getMails(): Collection
{
return $this->mails;
}
public function addMail(Mail $mail): static
{
if (!$this->mails->contains($mail)) {
$this->mails->add($mail);
$mail->setInternaute($this);
}
return $this;
}
public function removeMail(Mail $mail): static
{
if ($this->mails->removeElement($mail)) {
// set the owning side to null (unless already changed)
if ($mail->getInternaute() === $this) {
$mail->setInternaute(null);
}
}
return $this;
}
public function getLoyaltyCard(): ?string
{
return $this->loyalty_card;
}
public function setLoyaltyCard(?string $loyalty_card): static
{
$this->loyalty_card = $loyalty_card;
return $this;
}
public function __toString(): string
{
return sprintf('Internaute: %s %s (%s)', $this->firstname, $this->lastname, $this->email);
}
}