<?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\HomeRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=HomeRepository::class)
* @ApiResource(
* shortName="address-home",
* attributes={
* "normalization_context"={
* "groups"={
* "AddressHome:output",
* "AddressHome:io",
* }
* },
* "denormalization_context"={
* "groups"={
* "AddressHome:input",
* "AddressHome:io",
* }
* }
* },
* collectionOperations={
* "post"={
* "method"="POST",
* "access_control"="is_granted('ROLE_USER')"
* },
* "get"={
* "method"="GET",
* "access_control"="is_granted('ROLE_USER')",
* },
* },
* itemOperations={
* "get"={
* "method"="GET",
* "access_control"="is_granted('ROLE_USER')",
* },
* "put"={
* "method"="PUT",
* "access_control"="is_granted('ROLE_USER')",
* "validation_groups"={"put_address_home"}
* },
* },
* )
*/
class Home extends Address
{
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="addressesHome")
* @ORM\JoinColumn(nullable=false)
* @SerializedName("user")
* @Groups({
* "AddressHome:io",
* })
*/
private $user;
/**
* @var Department
*
* @ORM\ManyToOne(targetEntity="App\Entity\Segmentation\Department", inversedBy="address")
*/
private $department;
/**
* @ORM\Column(type="string", length=10, nullable=true)
* @SerializedName("phone_number")
* @Assert\Length(max="10")
* @Groups({
* "AddressHome:io",
* "User:io",
* })
*/
private ?string $phoneNumber = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @SerializedName("extra_information")
* @Groups({
* "AddressHome:io",
* "User:io",
* })
*/
private ?string $extraInformation = null;
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Department
*/
public function getDepartment(): Department
{
return $this->department;
}
/**
* @param Department $department
*
* @return Address
*/
public function setDepartment(Department $department): Address
{
$this->department = $department;
return $this;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): self
{
$this->phoneNumber = $phoneNumber;
return $this;
}
public function getExtraInformation(): ?string
{
return $this->extraInformation;
}
public function setExtraInformation(?string $extraInformation): self
{
$this->extraInformation = $extraInformation;
return $this;
}
}