<?php
namespace App\Entity;
use App\Entity\SuperClass\BaseEntity;
use App\Repository\ProfileRepository;
use App\Validator\IsValidOwner;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=ProfileRepository::class)
*/
class Profile extends BaseEntity
{
/**
* @Assert\NotBlank()
* @ORM\Column(type="string", length=255)
*/
private $f_name;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
*/
private $l_name;
/**
* @ORM\Column(type="date", nullable=true )
* @Assert\NotBlank()
*/
private ?DateTime $dob = null;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank()
*/
private $gender;
/**
* @Assert\NotBlank()
* @ORM\Column(type="string", length=255)
*/
private $phone;
/**
* @ORM\OneToOne(targetEntity=User::class, inversedBy="profile", cascade={"persist", "remove"})
* @IsValidOwner()
*/
protected ?User $owner;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="profiles")
*/
private $created_by;
public function getFName(): ?string
{
return $this->f_name;
}
public function setFName(string $f_name): self
{
$this->f_name = $f_name;
return $this;
}
public function getLName(): ?string
{
return $this->l_name;
}
public function setLName(string $l_name): self
{
$this->l_name = $l_name;
return $this;
}
public function getDob(): ?string
{
if (!is_null($this->dob)) {
return $this->dob->format('Y-m-d');
}
return '';
}
/**
* @throws \Exception
*/
public function setDob($dob): self
{
$this->dob = new DateTime($dob);
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(string $gender): self
{
$this->gender = $gender;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $created_by): self
{
$this->owner = $created_by;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->created_by;
}
public function setCreatedBy(?User $created_by): self
{
$this->created_by = $created_by;
return $this;
}
}