<?php
namespace App\Containers\CompanySection\UserContainer\Entities;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\DBAL\Types\Types;
use App\Ship\Entities\UserEntity;
use App\Containers\CompanySection\UserContainer\Data\Repositories\GuestRepository;
/**
* Гость
*/
#[ORM\Entity(repositoryClass: GuestRepository::class)]
#[ORM\Table(name: '`company_guest`')]
class GuestEntity extends UserEntity
{
// Токен
#[ORM\Column(type: Types::STRING, nullable: false)]
private string $token;
// Данные
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?string $data = null;
public function getToken(): string
{
return $this->token;
}
public function setToken($token)
{
$this->token = $token;
return $this;
}
public function getData()
{
return json_decode($this->data ?? '[]', true);
}
public function setData($data)
{
$this->data = json_encode($data);
return $this;
}
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_GUEST
$roles[] = 'ROLE_USER_GUEST';
return \array_unique($roles);
}
}