src/Entity/User.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\UserRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use ApiPlatform\Core\Annotation\ApiFilter;
  11. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  12. use App\EventListener\UserListener;
  13. /**
  14.  * @ORM\Entity(repositoryClass=UserRepository::class)
  15.  * @ORM\HasLifecycleCallbacks()
  16.  * @ORM\EntityListeners({"App\EventListener\UserListener"})
  17.  * @ORM\Table(name="`user`")
  18.  * @UniqueEntity(fields={"username"}, message="There is already an account with this username")
  19.  * @ApiResource(
  20.  *     normalizationContext={"groups"={"user:read", "base:read", "assign:read"}},
  21.  *     denormalizationContext={"groups"={"user:write", "base:write", "assign:write"}},
  22.  * )
  23.  * @ApiFilter(
  24.  *     SearchFilter::class,
  25.  *     properties={
  26.  *          "email": "exact",
  27.  *          "isAmbassador": "exact",
  28.  *          "ambassador": "exact",
  29.  *     }
  30.  * )
  31.  */
  32. class User implements UserInterfacePasswordAuthenticatedUserInterface
  33. {
  34.     /**
  35.      * @ORM\Id
  36.      * @ORM\GeneratedValue
  37.      * @ORM\Column(type="integer")
  38.      * @Groups({"user:read"})
  39.      */
  40.     private $id;
  41.     /**
  42.      * @ORM\Column(type="string", length=180, unique=false)
  43.      * @Groups({"user:read", "user:write", "assign:read"})
  44.      */
  45.     private $email;
  46.     /**
  47.      * @ORM\Column(type="json")
  48.      * @Groups({"user:read", "user:write", "assign:read"})
  49.      */
  50.     private $roles = [];
  51.     /**
  52.      * @var string The hashed password
  53.      * @ORM\Column(type="string")
  54.      */
  55.     private $password '';
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      * @Groups({"user:read", "user:write", "assign:read"})
  59.      */
  60.     private $firstName;
  61.     /**
  62.      * @ORM\Column(type="string", length=255, nullable=true)
  63.      * @Groups({"user:read", "user:write", "assign:read"})
  64.      */
  65.     private $lastName;
  66.     /**
  67.      * @ORM\Column(type="string", length=255, nullable=true)
  68.      * @Groups({"user:read", "user:write", "assign:read"})
  69.      */
  70.     private $phoneNumber;
  71.     /**
  72.      * @ORM\Column(type="string", length=255, nullable=true)
  73.      * @Groups({"user:read", "user:write", "assign:read"})
  74.      */
  75.     private $membershipLevel;
  76.     /**
  77.      * @ORM\Column(type="boolean", options={"default": false})
  78.      * @Groups({"user:read", "user:write", "assign:read"})
  79.      */
  80.     private $isAmbassador  false;
  81.     /**
  82.      * @ORM\ManyToOne(targetEntity=Member::class, inversedBy="users")
  83.      * @Groups({"user:read", "user:write", "assign:read"})
  84.      */
  85.     private $member;
  86.     /**
  87.      * @ORM\Column(type="string", length=255, nullable=true)
  88.      */
  89.     private $resetHash;
  90.     /**
  91.      * @ORM\Column(type="datetime", nullable=true)
  92.      */
  93.     private $resetHashExpire;
  94.     /**
  95.      * @ORM\Column(type="string", length=255, nullable=true)
  96.      * @Groups({"user:read", "user:write", "assign:read"})
  97.      */
  98.     private $title;
  99.     /**
  100.      * @ORM\Column(type="string", length=255, nullable=true)
  101.      * @Groups({"user:read", "user:write", "assign:read"})
  102.      */
  103.     private $phoneExt;
  104.     /**
  105.      * @ORM\Column(type="string", length=255, nullable=true)
  106.      * @Groups({"user:read", "user:write", "assign:read"})
  107.      */
  108.     private $mobile;
  109.     /**
  110.      * @ORM\Column(type="string", length=255, nullable=true)
  111.      * @Groups({"user:read", "user:write", "assign:read"})
  112.      */
  113.     private $contact_type;
  114.     /**
  115.      * @ORM\Column(type="string", length=255, nullable=true)
  116.      * @Groups({"user:read", "user:write", "assign:read"})
  117.      */
  118.     private $department;
  119.     /**
  120.      * @ORM\Column(type="string", length=255, nullable=true)
  121.      * @Groups({"user:read", "user:write", "assign:read"})
  122.      */
  123.     private $fax;
  124.     /**
  125.      * @ORM\Column(type="string", length=255, nullable=true)
  126.      * @Groups({"user:read", "user:write", "assign:read"})
  127.      */
  128.     private $user_type;
  129.     /**
  130.      * @ORM\Column(type="datetime", nullable=true)
  131.      * @Groups({"user:read", "user:write", "assign:read"})
  132.      */
  133.     private $lastLogin;
  134.     /**
  135.      * @ORM\Column(type="boolean", options={"default": true})
  136.      */
  137.     private $isNew true;
  138.     /**
  139.      * @ORM\Column(type="boolean", options={"default": false})
  140.      */
  141.     private $internal  false;
  142.     /**
  143.      * @ORM\Column(type="string", length=255, nullable=false, unique=true)
  144.      * @Groups({"user:read", "user:write", "assign:read"})
  145.      */
  146.     private $username;
  147.     /**
  148.      * @ORM\Column(type="boolean", options={"default": false})
  149.      */
  150.     private $acceptedTerms  false;
  151.     /**
  152.      * @ORM\Column(type="datetime", nullable=true)
  153.      */
  154.     private $acceptedTermsTime ;
  155.     /**
  156.      * @ORM\ManyToOne(targetEntity=User::class)
  157.      * @Groups({"user:read", "user:write", "assign:read"})
  158.      */
  159.     private $ambassador;
  160.     /**
  161.      * @ORM\Column(type="date", nullable=true)
  162.      */
  163.     private $ambassadorAssignedDate;
  164.     /**
  165.      * @ORM\Column(type="string", length=255, nullable=true)
  166.      */
  167.     private $requestStatus;
  168.     /**
  169.      * @ORM\Column(type="boolean", options={"default": false})
  170.      */
  171.     private $userAcceptedTerms2  false;
  172.     /**
  173.      * @ORM\Column(type="datetime", nullable=true)
  174.      */
  175.     private $userAcceptedTermsTime2 ;
  176.     /**
  177.      * @ORM\Column(type="datetime", nullable=true)
  178.      */
  179.     private $downloadNdaTime ;
  180.     public function getId(): ?int
  181.     {
  182.         return $this->id;
  183.     }
  184.     public function getEmail(): ?string
  185.     {
  186.         return $this->email;
  187.     }
  188.     public function setEmail(string $email): self
  189.     {
  190.         $this->email $email;
  191.         return $this;
  192.     }
  193.     /**
  194.      * A visual identifier that represents this user.
  195.      *
  196.      * @see UserInterface
  197.      */
  198.     public function getUserIdentifier(): string
  199.     {
  200.         return (string)$this->username;
  201.     }
  202.     /**
  203.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  204.      */
  205.     public function getUsername(): string
  206.     {
  207.         return (string)$this->username;
  208.     }
  209.     /**
  210.      * @see UserInterface
  211.      */
  212.     public function getRoles(): array
  213.     {
  214.         $roles $this->roles;
  215.         // guarantee every user at least has ROLE_USER
  216.         $roles[] = 'ROLE_USER';
  217.         return array_unique($roles);
  218.     }
  219.     public function setRoles(array $roles): self
  220.     {
  221.         $this->roles $roles;
  222.         return $this;
  223.     }
  224.     /**
  225.      * @see PasswordAuthenticatedUserInterface
  226.      */
  227.     public function getPassword(): string
  228.     {
  229.         return $this->password;
  230.     }
  231.     public function setPassword($password null): self
  232.     {
  233.         if ($password) {
  234.             $this->password $password;
  235.         }
  236.         return $this;
  237.     }
  238.     /**
  239.      * Returning a salt is only needed, if you are not using a modern
  240.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  241.      *
  242.      * @see UserInterface
  243.      */
  244.     public function getSalt(): ?string
  245.     {
  246.         return null;
  247.     }
  248.     /**
  249.      * @see UserInterface
  250.      */
  251.     public function eraseCredentials()
  252.     {
  253.         // If you store any temporary, sensitive data on the user, clear it here
  254.         // $this->plainPassword = null;
  255.     }
  256.     public function getFirstName(): ?string
  257.     {
  258.         return $this->firstName;
  259.     }
  260.     public function setFirstName(string $firstName): self
  261.     {
  262.         $this->firstName $firstName;
  263.         return $this;
  264.     }
  265.     public function getLastName(): ?string
  266.     {
  267.         return $this->lastName;
  268.     }
  269.     public function setLastName(string $lastName): self
  270.     {
  271.         $this->lastName $lastName;
  272.         return $this;
  273.     }
  274.     public function getPhoneNumber(): ?string
  275.     {
  276.         return $this->phoneNumber;
  277.     }
  278.     public function setPhoneNumber(?string $phoneNumber): self
  279.     {
  280.         $this->phoneNumber $phoneNumber;
  281.         return $this;
  282.     }
  283.     public function getName()
  284.     {
  285.         return trim($this->firstName ' ' $this->lastName);
  286.     }
  287.     public function getMembershipLevel(): ?string
  288.     {
  289.         return $this->membershipLevel;
  290.     }
  291.     public function setMembershipLevel(?string $membershipLevel): self
  292.     {
  293.         $this->membershipLevel $membershipLevel;
  294.         return $this;
  295.     }
  296.     public function getMember(): ?Member
  297.     {
  298.         return $this->member;
  299.     }
  300.     public function setMember(?Member $member): self
  301.     {
  302.         $this->member $member;
  303.         return $this;
  304.     }
  305.     public function getResetHash(): ?string
  306.     {
  307.         return $this->resetHash;
  308.     }
  309.     public function setResetHash(?string $resetHash): self
  310.     {
  311.         $this->resetHash $resetHash;
  312.         return $this;
  313.     }
  314.     public function getResetHashExpire(): ?\DateTimeInterface
  315.     {
  316.         return $this->resetHashExpire;
  317.     }
  318.     public function setResetHashExpire(?\DateTimeInterface $resetHashExpire): self
  319.     {
  320.         $this->resetHashExpire $resetHashExpire;
  321.         return $this;
  322.     }
  323.     public function getTitle(): ?string
  324.     {
  325.         return $this->title;
  326.     }
  327.     public function setTitle(?string $title): self
  328.     {
  329.         $this->title $title;
  330.         return $this;
  331.     }
  332.     public function getPhoneExt(): ?string
  333.     {
  334.         return $this->phoneExt;
  335.     }
  336.     public function setPhoneExt(?string $phoneExt): self
  337.     {
  338.         $this->phoneExt $phoneExt;
  339.         return $this;
  340.     }
  341.     public function getMobile(): ?string
  342.     {
  343.         return $this->mobile;
  344.     }
  345.     public function setMobile(?string $mobile): self
  346.     {
  347.         $this->mobile $mobile;
  348.         return $this;
  349.     }
  350.     public function getContactType(): ?string
  351.     {
  352.         return $this->contact_type;
  353.     }
  354.     public function setContactType(?string $contact_type): self
  355.     {
  356.         $this->contact_type $contact_type;
  357.         return $this;
  358.     }
  359.     public function getDepartment(): ?string
  360.     {
  361.         return $this->department;
  362.     }
  363.     public function setDepartment(?string $department): self
  364.     {
  365.         $this->department $department;
  366.         return $this;
  367.     }
  368.     public function getFax(): ?string
  369.     {
  370.         return $this->fax;
  371.     }
  372.     public function setFax(?string $fax): self
  373.     {
  374.         $this->fax $fax;
  375.         return $this;
  376.     }
  377.     public function getUserType(): ?string
  378.     {
  379.         return $this->user_type;
  380.     }
  381.     public function setUserType(?string $user_type): self
  382.     {
  383.         $this->user_type $user_type;
  384.         return $this;
  385.     }
  386.     public function getLastLogin(): ?\DateTimeInterface
  387.     {
  388.         return $this->lastLogin;
  389.     }
  390.     public function setLastLogin(?\DateTimeInterface $lastLogin): self
  391.     {
  392.         $this->lastLogin $lastLogin;
  393.         return $this;
  394.     }
  395.     public function isIsNew(): ?bool
  396.     {
  397.         return $this->isNew;
  398.     }
  399.     public function setIsNew(bool $isNew): self
  400.     {
  401.         $this->isNew $isNew;
  402.         return $this;
  403.     }
  404.     public function setUsername(?string $username): self
  405.     {
  406.         $this->username $username;
  407.         return $this;
  408.     }
  409.     public function isInternal(): ?bool
  410.     {
  411.         return $this->internal;
  412.     }
  413.     public function setInternal(bool $internal): self
  414.     {
  415.         $this->internal $internal;
  416.         return $this;
  417.     }
  418.     public function acceptedTerms(): ?bool
  419.     {
  420.         return $this->acceptedTerms;
  421.     }
  422.     public function setAcceptedTerms(bool $acceptedTerms): self
  423.     {
  424.         $this->acceptedTerms $acceptedTerms;
  425.         return $this;
  426.     }
  427.     public function getAcceptedTermsTime(): ?\DateTimeInterface
  428.     {
  429.         return $this->acceptedTermsTime;
  430.     }
  431.     public function setAcceptedTermsTime(?\DateTimeInterface $acceptedTermsTime): self
  432.     {
  433.         $this->acceptedTermsTime $acceptedTermsTime;
  434.         return $this;
  435.     }
  436.     public function isAmbassador(): ?bool
  437.     {
  438.         return $this->isAmbassador;
  439.     }
  440.     public function setIsAmbassador(bool $isAmbassador): self
  441.     {
  442.         $this->isAmbassador $isAmbassador;
  443.         return $this;
  444.     }
  445.     public function getAmbassador(): ?User
  446.     {
  447.         return $this->ambassador;
  448.     }
  449.     public function setAmbassador(?User $user): self
  450.     {
  451.         $this->ambassador $user;
  452.         return $this;
  453.     }
  454.     public function getAmbassadorAssignedDate(): ?\DateTimeInterface
  455.     {
  456.         return $this->ambassadorAssignedDate;
  457.     }
  458.     public function setAmbassadorAssignedDate(?\DateTimeInterface $ambassadorAssignedDate): self
  459.     {
  460.         $this->ambassadorAssignedDate $ambassadorAssignedDate;
  461.         return $this;
  462.     }
  463.     public function getRequestStatus(): ?string
  464.     {
  465.         return $this->requestStatus;
  466.     }
  467.     public function setRequestStatus(?string $requestStatus): self
  468.     {
  469.         $this->requestStatus $requestStatus;
  470.         return $this;
  471.     }
  472.     public function getUserAcceptedTerms2(): ?bool
  473.     {
  474.         return $this->userAcceptedTerms2;
  475.     }
  476.     public function setUserAcceptedTerms2(bool $userAcceptedTerms2): self
  477.     {
  478.         $this->userAcceptedTerms2 $userAcceptedTerms2;
  479.         return $this;
  480.     }
  481.     public function getUserAcceptedTermsTime2(): ?\DateTimeInterface
  482.     {
  483.         return $this->userAcceptedTermsTime2;
  484.     }
  485.     public function setUserAcceptedTermsTime2(?\DateTimeInterface $userAcceptedTermsTime2): self
  486.     {
  487.         $this->userAcceptedTermsTime2 $userAcceptedTermsTime2;
  488.         return $this;
  489.     }
  490.     public function getDownloadNdaTime(): ?\DateTimeInterface
  491.     {
  492.         return $this->downloadNdaTime;
  493.     }
  494.     public function setDownloadNdaTime(?\DateTimeInterface $downloadNdaTime): self
  495.     {
  496.         $this->downloadNdaTime $downloadNdaTime;
  497.         return $this;
  498.     }
  499. }