src/Entity/UserGuest.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Model\Enum\Occupation;
  4. use App\Repository\UserGuestRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass=UserGuestRepository::class)
  9.  */
  10. class UserGuest
  11. {
  12.     use Timestampable;
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private ?int $id null;
  19.     /**
  20.      * @ORM\OneToOne(targetEntity=User::class, inversedBy="userGuest", cascade={"persist", "remove"})
  21.      * @ORM\JoinColumn(nullable=false)
  22.      * @Assert\NotBlank()
  23.      * @Assert\Valid()
  24.      */
  25.     private ?User $user null;
  26.     /**
  27.      * @ORM\Embedded(class=Name::class)
  28.      * @Assert\Valid()
  29.      */
  30.     private Name $name;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      * @Assert\NotBlank(
  34.      *     message="選択してください",
  35.      *     groups="guest"
  36.      * )
  37.      * @Assert\Length(
  38.      *     max=255
  39.      * )
  40.      */
  41.     private ?string $schoolName null;
  42.     /**
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      * @Assert\NotBlank(
  45.      *     message="選択してください",
  46.      *     groups="guest"
  47.      * )
  48.      * @Assert\Length(
  49.      *     max=255
  50.      * )
  51.      */
  52.     private ?string $graduationYear null;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=true)
  55.      * @Assert\NotBlank(
  56.      *     message="選択してください",
  57.      *     groups="guest"
  58.      * )
  59.      * @Assert\Length(
  60.      *     max=255
  61.      * )
  62.      */
  63.     private ?string $prefecture null;
  64.     /**
  65.      * @ORM\Column(type="string", length=255, nullable=true)
  66.      * @Assert\NotBlank(
  67.      *     groups="guest"
  68.      * )
  69.      * @Assert\Length(
  70.      *     max=255
  71.      * )
  72.      */
  73.     private ?string $workplaceName null;
  74.     /**
  75.      * @ORM\Column(type="string", length=255, nullable=true)
  76.      * @Assert\Length(
  77.      *     max=255
  78.      * )
  79.      */
  80.     private ?string $phoneNumber null;
  81.     /**
  82.      * @ORM\Column(type="boolean")
  83.      */
  84.     private bool $sendingEmailAllowed false;
  85.     /**
  86.      * @ORM\Column(type="OccupationType", nullable=true)
  87.      * @Assert\NotBlank(
  88.      *     message="選択してください",
  89.      *     groups="guest"
  90.      * )
  91.      */
  92.     private ?Occupation $occupation;
  93.     /**
  94.      * only for front form.
  95.      */
  96.     public bool $privacyCheck false;
  97.     /**
  98.      * only for front form.
  99.      */
  100.     public bool $termCheck false;
  101.     /**
  102.      * UserGuest constructor.
  103.      */
  104.     public function __construct()
  105.     {
  106.         $this->name = new Name();
  107.     }
  108.     public static function create(): UserGuest
  109.     {
  110.         $user = new User();
  111.         $user->setRole(User::ROLE_GUEST);
  112. //        $user->setIsEnabled(false);
  113.         $guest = new static();
  114.         $user->setUserGuest($guest);
  115.         return $guest;
  116.     }
  117.     public function getId(): ?int
  118.     {
  119.         return $this->id;
  120.     }
  121.     public function getUser(): ?User
  122.     {
  123.         return $this->user;
  124.     }
  125.     public function setUser(User $user): self
  126.     {
  127.         $this->user $user;
  128.         return $this;
  129.     }
  130.     public function getName(): Name
  131.     {
  132.         return $this->name;
  133.     }
  134.     public function setName(Name $name): self
  135.     {
  136.         $this->name $name;
  137.         return $this;
  138.     }
  139.     public function getSchoolName(): ?string
  140.     {
  141.         return $this->schoolName;
  142.     }
  143.     public function setSchoolName(?string $schoolName): self
  144.     {
  145.         $this->schoolName $schoolName;
  146.         return $this;
  147.     }
  148.     public function getGraduationYear(): ?string
  149.     {
  150.         return $this->graduationYear;
  151.     }
  152.     public function setGraduationYear(?string $graduationYear): self
  153.     {
  154.         $this->graduationYear $graduationYear;
  155.         return $this;
  156.     }
  157.     public function getPrefecture(): ?string
  158.     {
  159.         return $this->prefecture;
  160.     }
  161.     public function setPrefecture(?string $prefecture): self
  162.     {
  163.         $this->prefecture $prefecture;
  164.         return $this;
  165.     }
  166.     public function getWorkplaceName(): ?string
  167.     {
  168.         return $this->workplaceName;
  169.     }
  170.     public function setWorkplaceName(?string $workplaceName): self
  171.     {
  172.         $this->workplaceName $workplaceName;
  173.         return $this;
  174.     }
  175.     public function getPhoneNumber(): ?string
  176.     {
  177.         return $this->phoneNumber;
  178.     }
  179.     public function setPhoneNumber(?string $phoneNumber): self
  180.     {
  181.         $this->phoneNumber $phoneNumber;
  182.         return $this;
  183.     }
  184.     public function getSendingEmailAllowed(): bool
  185.     {
  186.         return $this->sendingEmailAllowed;
  187.     }
  188.     public function setSendingEmailAllowed(bool $sendingEmailAllowed): self
  189.     {
  190.         $this->sendingEmailAllowed $sendingEmailAllowed;
  191.         return $this;
  192.     }
  193.     public function getOccupation(): ?Occupation
  194.     {
  195.         return $this->occupation;
  196.     }
  197.     public function setOccupation(?Occupation $occupation): self
  198.     {
  199.         $this->occupation $occupation;
  200.         return $this;
  201.     }
  202. }