<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation AS Serializer;
use Symfony\Component\Validator\Constraints AS Validation;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*
* @Serializer\ExclusionPolicy("all")
* @Serializer\AccessorOrder("custom", custom = {"id", "civility", "firstname", "lastname", "birthdate", "email", "phone", "mobile", "address", "enabled", "roles"})
*/
class User extends BaseUser{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Serializer\Expose()
*/
protected $id;
/**
* @var string | null
* @ORM\Column(type="string", length=10, nullable=true)
*
* @Validation\NotBlank()
* @Validation\Choice({"Monsieur", "Madame"})
* @Serializer\Expose()
*/
protected $civility;
/**
* @var string | null
* @ORM\Column(type="string", length=70, nullable=true)
*
* @Validation\NotBlank()
* @Serializer\Expose()
*/
protected $firstname;
/**
* @var string | null
* @ORM\Column(type="string", length=70, nullable=true)
*
* @Validation\NotBlank()
* @Serializer\Expose()
*/
protected $lastname;
/**
* @var \DateTime | null
* @ORM\Column(name="birthdate", type="datetime", nullable=true)
*
* @Serializer\Expose()
*/
protected $birthdate;
/**
* @var string | null
* @ORM\Column(type="string", length=20, nullable=true)
*
* @Serializer\Expose()
*/
protected $phone;
/**
* @var string | null
* @ORM\Column(type="string", length=20, nullable=true)
*
* @Serializer\Expose()
*/
protected $mobile;
/**
* @var Address | null
* @ORM\OneToOne(targetEntity="Address", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
* @ORM\JoinColumn(name="address_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*
* @Serializer\Expose()
*/
protected $address;
/**
* @var string | null
* @ORM\Column(type="string", length=50, nullable=true)
*/
protected $facebookId;
/**
* @var string | null
* @ORM\Column(type="string", length=50, nullable=true)
*/
protected $googleId;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Image", mappedBy="User", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="image_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*
* @Serializer\Expose()
*/
private $image;
/**
* @var \DateTime | null
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*
* @Serializer\Expose()
*/
protected $createdAt;
/**
* @var User | null
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="created_by", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*/
protected $createdBy;
/**
* @var \DateTime | null
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
protected $updatedAt;
/**
* @var User | null
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="updated_by", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*/
protected $updatedBy;
/**
* @var \DateTime | null
* @ORM\Column(name="deleted_at", type="datetime", nullable=true)
*/
protected $deletedAt;
/**
* @var User | null
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="deleted_by", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*/
protected $deletedBy;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return null|string
*/
public function getCivility(): ?string
{
return $this->civility;
}
/**
* @param null|string $civility
* @return User
*/
public function setCivility(?string $civility): User
{
$this->civility = $civility;
return $this;
}
/**
* @return null|string
*/
public function getFirstname(): ?string
{
return $this->firstname;
}
/**
* @param null|string $firstname
* @return User
*/
public function setFirstname(?string $firstname): User
{
$this->firstname = $firstname;
return $this;
}
/**
* @return null|string
*/
public function getLastname(): ?string
{
return $this->lastname;
}
/**
* @param null|string $lastname
* @return User
*/
public function setLastname(?string $lastname): User
{
$this->lastname = $lastname;
return $this;
}
/**
* @return \DateTime|null
*/
public function getBirthdate(): ?\DateTime
{
return $this->birthdate;
}
/**
* @param \DateTime|null $birthdate
* @return User
*/
public function setBirthdate(?\DateTime $birthdate): User
{
$this->birthdate = $birthdate;
return $this;
}
/**
* @return null|string
*/
public function getPhone(): ?string
{
return $this->phone;
}
/**
* @param null|string $phone
* @return User
*/
public function setPhone(?string $phone): User
{
$this->phone = $phone;
return $this;
}
/**
* @return null|string
*/
public function getMobile(): ?string
{
return $this->mobile;
}
/**
* @param null|string $mobile
* @return User
*/
public function setMobile(?string $mobile): User
{
$this->mobile = $mobile;
return $this;
}
/**
* @return Address|null
*/
public function getAddress(): ?Address
{
return $this->address;
}
/**
* @param Address|null $address
* @return User
*/
public function setAddress(?Address $address): User
{
$this->address = $address;
return $this;
}
/**
* @return null|string
*/
public function getFacebookId(): ?string
{
return $this->facebookId;
}
/**
* @param null|string $facebookId
* @return User
*/
public function setFacebookId(?string $facebookId): User
{
$this->facebookId = $facebookId;
return $this;
}
/**
* @return null|string
*/
public function getGoogleId(): ?string
{
return $this->googleId;
}
/**
* @param null|string $googleId
* @return User
*/
public function setGoogleId(?string $googleId): User
{
$this->googleId = $googleId;
return $this;
}
/**
* @param Image|null $image
* @return User
*/
public function setImage(Image $image = null)
{
$this->image = $image;
return $this;
}
/**
* @return Image
*/
public function getImage()
{
return $this->image;
}
/**
* @return \DateTime|null
*/
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
/**
* @param \DateTime|null $createdAt
* @return User
*/
public function setCreatedAt(?\DateTime $createdAt): User
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return User|null
*/
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
/**
* @param User|null $createdBy
* @return User
*/
public function setCreatedBy(?User $createdBy): User
{
$this->createdBy = $createdBy;
return $this;
}
/**
* @return \DateTime|null
*/
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
/**
* @param \DateTime|null $updatedAt
* @return User
*/
public function setUpdatedAt(?\DateTime $updatedAt): User
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return User|null
*/
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
/**
* @param User|null $updatedBy
* @return User
*/
public function setUpdatedBy(?User $updatedBy): User
{
$this->updatedBy = $updatedBy;
return $this;
}
/**
* @return \DateTime|null
*/
public function getDeletedAt(): ?\DateTime
{
return $this->deletedAt;
}
/**
* @param \DateTime|null $deletedAt
* @return User
*/
public function setDeletedAt(?\DateTime $deletedAt): User
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* @return User|null
*/
public function getDeletedBy(): ?User
{
return $this->deletedBy;
}
/**
* @param User|null $deletedBy
* @return User
*/
public function setDeletedBy(?User $deletedBy): User
{
$this->deletedBy = $deletedBy;
return $this;
}
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->createdAt = new \DateTime();
}
public function __toString()
{
return (string)$this->firstname." ".$this->lastname;
}
}