<?php
namespace App\Entity\User\Address;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Segmentation\Department;
use App\Entity\User\User;
use App\Repository\User\Address\DeliveryRepository;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\ExclusionPolicy;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=DeliveryRepository::class)
* @ExclusionPolicy("all")
* @ApiResource(
* shortName="address-delivery",
* attributes={
* "normalization_context"={
* "groups"={
* "AddressDelivery:output",
* "AddressDelivery:io",
* }
* },
* "denormalization_context"={
* "groups"={
* "AddressDelivery:input",
* "AddressDelivery:io",
* }
* }
* },
* collectionOperations={
* "post"={
* "method"="POST",
* "access_control"="is_granted('ROLE_USER')"
* },
* "get"={
* "method"="GET",
* "access_control"="is_granted('ROLE_USER')",
* },
* "public-post"={
* "method"="POST",
* "path"="/public/address-deliveries",
* "access_control"="is_granted('ROLE_PUBLIC')",
* "validation_groups"={"Default", "Create"}
* },
* },
* itemOperations={
* "get"={
* "method"="GET",
* "access_control"="is_granted('ROLE_USER')",
* },
* "put"={
* "method"="PUT",
* "access_control"="is_granted('ROLE_USER')",
* "validation_groups"={"put_address_delivery"}
* },
* },
* )
*/
class Delivery extends Address
{
/**
* @ORM\Column(type="string", length=25)
* @SerializedName("first_name")
* @Assert\NotBlank()
* @Assert\Length(max="25")
* @Groups({
* "AddressDelivery:io",
* "User:io",
* })
*/
private string $firstName;
/**
* @ORM\Column(type="string", length=25)
* @SerializedName("last_name")
* @Assert\NotBlank()
* @Assert\Length(max="25")
* @Groups({
* "AddressDelivery:io",
* "User:io",
* })
*/
private string $lastName;
/**
* @ORM\Column(type="string", length=10, nullable=true)
* @SerializedName("phone_number")
* @Assert\Length(max="10")
* @Groups({
* "AddressDelivery:io",
* "User:io",
* })
*/
private ?string $phoneNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @SerializedName("extra_information")
* @Groups({
* "AddressDelivery:io",
* "User:io",
* })
*/
private ?string $extraInformation;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="addressesDelivery")
* @ORM\JoinColumn(nullable=false)
* @SerializedName("user")
* @Groups({
* "AddressDelivery:io",
* })
*/
private $user;
/**
* @var Department
*
* @ORM\ManyToOne(targetEntity="App\Entity\Segmentation\Department", inversedBy="delivery")
*/
private $department;
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getDepartment(): Department
{
return $this->department;
}
public function setDepartment(Department $department): Address
{
$this->department = $department;
return $this;
}
public function getFirstName(): string
{
return $this->firstName;
}
public function setFirstName(string $firstName): Delivery
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): string
{
return $this->lastName;
}
public function setLastName(string $lastName): Delivery
{
$this->lastName = $lastName;
return $this;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): Delivery
{
$this->phoneNumber = $phoneNumber;
return $this;
}
public function getExtraInformation(): ?string
{
return $this->extraInformation;
}
/**
* @param string|null $extraInformation
* @return Delivery
*/
public function setExtraInformation(?string $extraInformation): Delivery
{
$this->extraInformation = $extraInformation;
return $this;
}
}