src/Containers/CompanySection/UserContainer/Entities/GuestEntity.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Containers\CompanySection\UserContainer\Entities;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\DBAL\Types\Types;
  5. use App\Ship\Entities\UserEntity;
  6. use App\Containers\CompanySection\UserContainer\Data\Repositories\GuestRepository;
  7. /** 
  8.  * Гость
  9. */
  10. #[ORM\Entity(repositoryClassGuestRepository::class)]
  11. #[ORM\Table(name'`company_guest`')]
  12. class GuestEntity extends UserEntity
  13. {
  14.     // Токен
  15.     #[ORM\Column(typeTypes::STRINGnullablefalse)]
  16.     private string $token;
  17.     // Данные
  18.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  19.     private ?string $data null;
  20.     public function getToken(): string
  21.     {
  22.         return $this->token;
  23.     }
  24.     public function setToken($token)
  25.     {
  26.         $this->token $token;
  27.         return $this;
  28.     }
  29.     public function getData()
  30.     {
  31.         return json_decode($this->data ?? '[]'true);
  32.     }
  33.     public function setData($data)
  34.     {
  35.         $this->data json_encode($data);
  36.         return $this;
  37.     }
  38.     public function getRoles(): array
  39.     {
  40.         $roles $this->roles;
  41.         // guarantee every user at least has ROLE_GUEST
  42.         $roles[] = 'ROLE_USER_GUEST';
  43.         return \array_unique($roles);
  44.     }
  45. }