<?php namespace App\Entity; use App\Repository\CartItemParticipantRepository; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=CartItemParticipantRepository::class) */ class CartItemParticipant { const TYPE_ADULT = 'A'; const TYPE_CHILD = 'E'; /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $lastName; /** * @ORM\Column(type="string", length=255) */ private $firstName; /** * @ORM\Column(type="string", length=1) */ private $typeParticipant; /** * @ORM\ManyToOne(targetEntity=CartItem::class, inversedBy="participants") * @ORM\JoinColumn(nullable=false) */ private $cartItem; /** * @ORM\Column(type="date", nullable=true) */ private $birthDate; /** * Index to link participants between items (otherwise if item quantity > 1 we have all participants of all products linked to only one item) * @ORM\Column(type="integer", options={"default": 1}) */ private $quantityIndex = 1; public function __toString() { return strtoupper( $this->lastName ) . ' ' . $this->firstName . ' - ' . $this->birthDate->format( 'd/m/Y' ); } public function getId(): ?int { return $this->id; } public function getLastName(): ?string { return $this->lastName; } public function setLastName( string $lastName ): self { $this->lastName = $lastName; return $this; } public function getFirstName(): ?string { return $this->firstName; } public function setFirstName( string $firstName ): self { $this->firstName = $firstName; return $this; } public function getTypeParticipant(): ?string { return $this->typeParticipant; } public function setTypeParticipant( string $typeParticipant ): self { $this->typeParticipant = $typeParticipant; return $this; } public function getCartItem(): ?CartItem { return $this->cartItem; } public function setCartItem( ?CartItem $cartItem ): self { $this->cartItem = $cartItem; return $this; } public function getBirthDate(): ?DateTimeInterface { return $this->birthDate; } public function setBirthDate( ?DateTimeInterface $birthDate ): self { $this->birthDate = $birthDate; return $this; } public function getQuantityIndex(): ?int { return $this->quantityIndex; } public function setQuantityIndex( int $quantityIndex ): self { $this->quantityIndex = $quantityIndex; return $this; } }