<?php
namespace App\Containers\CrmSection\ClientContainer\Entities;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\DBAL\Types\Types;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Containers\CrmSection\ClientContainer\Entities\ClientEntity;
use App\Containers\CrmSection\ClientContainer\Data\Repositories\ClientOptionsRepository;
/**
* Настройки
*/
#[ORM\Entity(repositoryClass: ClientOptionsRepository::class)]
#[ORM\Table(name: '`crm_clients_options`')]
#[ORM\Index(columns: ['code'], name: 'crm_clients_options_custom_idx')]
class ClientOptionsEntity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
// Клиент
#[ORM\ManyToOne(targetEntity: ClientEntity::class)]
#[ORM\JoinColumn(name: 'client_id', referencedColumnName: 'id', nullable: false)]
private ClientEntity $client;
// Код
#[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
private string $code;
// Значение
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?string $value = null;
#[Gedmo\Timestampable(on: 'create')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
protected $createdAt;
#[Gedmo\Timestampable(on: 'update')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
protected $updatedAt;
public function getId()
{
return $this->id;
}
public function getClient()
{
return $this->client;
}
public function setClient($client)
{
$this->client = $client;
return $this;
}
public function getCode()
{
return $this->code;
}
public function setCode($code)
{
$this->code = $code;
return $this;
}
public function getValue()
{
return json_decode($this->value ?? '[]', true);
}
public function setValue($value)
{
$this->value = json_encode($value);
return $this;
}
}