src/Containers/CrmSection/ClientContainer/Entities/ClientOptionsEntity.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Containers\CrmSection\ClientContainer\Entities;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\DBAL\Types\Types;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use App\Containers\CrmSection\ClientContainer\Entities\ClientEntity;
  7. use App\Containers\CrmSection\ClientContainer\Data\Repositories\ClientOptionsRepository;
  8. /** 
  9.  * Настройки
  10. */
  11. #[ORM\Entity(repositoryClass: ClientOptionsRepository::class)]
  12. #[ORM\Table(name: '`crm_clients_options`')]
  13. #[ORM\Index(columns: ['code'], name: 'crm_clients_options_custom_idx')]
  14. class ClientOptionsEntity
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type: Types::INTEGER)]
  19.     private ?int $id = null;
  20.     // Клиент
  21.     #[ORM\ManyToOne(targetEntity: ClientEntity::class)]
  22.     #[ORM\JoinColumn(name: 'client_id', referencedColumnName: 'id', nullable: false)]
  23.     private ClientEntity $client;
  24.     // Код
  25.     #[ORM\Column(type: Types::STRING, length: 255, nullable: false)]
  26.     private string $code;
  27.     // Значение
  28.     #[ORM\Column(type: Types::JSON, nullable: true)]
  29.     private ?string $value = null;
  30.     #[Gedmo\Timestampable(on: 'create')]
  31.     #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
  32.     protected $createdAt;
  33.     #[Gedmo\Timestampable(on: 'update')]
  34.     #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
  35.     protected $updatedAt;
  36.     public function getId()
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getClient()
  41.     {
  42.         return $this->client;
  43.     }
  44.     public function setClient($client)
  45.     {
  46.         $this->client = $client;
  47.         return $this;
  48.     }
  49.     public function getCode()
  50.     {
  51.         return $this->code;
  52.     }
  53.     public function setCode($code)
  54.     {
  55.         $this->code = $code;
  56.         return $this;
  57.     }
  58.     public function getValue()
  59.     {
  60.         return json_decode($this->value ?? '[]', true);
  61.     }
  62.     public function setValue($value)
  63.     {
  64.         $this->value = json_encode($value);
  65.         return $this;
  66.     }
  67. }