<?php
namespace App\Entity;
use App\Model\Enum\Occupation;
use App\Repository\UserGuestRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=UserGuestRepository::class)
*/
class UserGuest
{
use Timestampable;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\OneToOne(targetEntity=User::class, inversedBy="userGuest", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank()
* @Assert\Valid()
*/
private ?User $user = null;
/**
* @ORM\Embedded(class=Name::class)
* @Assert\Valid()
*/
private Name $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank(
* message="選択してください",
* groups="guest"
* )
* @Assert\Length(
* max=255
* )
*/
private ?string $schoolName = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank(
* message="選択してください",
* groups="guest"
* )
* @Assert\Length(
* max=255
* )
*/
private ?string $graduationYear = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank(
* message="選択してください",
* groups="guest"
* )
* @Assert\Length(
* max=255
* )
*/
private ?string $prefecture = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank(
* groups="guest"
* )
* @Assert\Length(
* max=255
* )
*/
private ?string $workplaceName = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\Length(
* max=255
* )
*/
private ?string $phoneNumber = null;
/**
* @ORM\Column(type="boolean")
*/
private bool $sendingEmailAllowed = false;
/**
* @ORM\Column(type="OccupationType", nullable=true)
* @Assert\NotBlank(
* message="選択してください",
* groups="guest"
* )
*/
private ?Occupation $occupation;
/**
* only for front form.
*/
public bool $privacyCheck = false;
/**
* only for front form.
*/
public bool $termCheck = false;
/**
* UserGuest constructor.
*/
public function __construct()
{
$this->name = new Name();
}
public static function create(): UserGuest
{
$user = new User();
$user->setRole(User::ROLE_GUEST);
// $user->setIsEnabled(false);
$guest = new static();
$user->setUserGuest($guest);
return $guest;
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
public function getName(): Name
{
return $this->name;
}
public function setName(Name $name): self
{
$this->name = $name;
return $this;
}
public function getSchoolName(): ?string
{
return $this->schoolName;
}
public function setSchoolName(?string $schoolName): self
{
$this->schoolName = $schoolName;
return $this;
}
public function getGraduationYear(): ?string
{
return $this->graduationYear;
}
public function setGraduationYear(?string $graduationYear): self
{
$this->graduationYear = $graduationYear;
return $this;
}
public function getPrefecture(): ?string
{
return $this->prefecture;
}
public function setPrefecture(?string $prefecture): self
{
$this->prefecture = $prefecture;
return $this;
}
public function getWorkplaceName(): ?string
{
return $this->workplaceName;
}
public function setWorkplaceName(?string $workplaceName): self
{
$this->workplaceName = $workplaceName;
return $this;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): self
{
$this->phoneNumber = $phoneNumber;
return $this;
}
public function getSendingEmailAllowed(): bool
{
return $this->sendingEmailAllowed;
}
public function setSendingEmailAllowed(bool $sendingEmailAllowed): self
{
$this->sendingEmailAllowed = $sendingEmailAllowed;
return $this;
}
public function getOccupation(): ?Occupation
{
return $this->occupation;
}
public function setOccupation(?Occupation $occupation): self
{
$this->occupation = $occupation;
return $this;
}
}