Files
svo/kernel/app_modules/user_custom_fields/models/CustomField.php
2025-07-14 12:15:41 +03:00

72 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace kernel\app_modules\user_custom_fields\models;
use Illuminate\Database\Eloquent\Model;
// Добавить @property
/**
* @property int $id
* @property int $status
* @property string $slug
* @property string $label
* @property string $type
* @property string $entity
* @property string $field_options
*/
class CustomField extends Model
{
const DISABLE_STATUS = 0;
const ACTIVE_STATUS = 1;
const TYPE_STRING = 'string';
const TYPE_SELECT = 'select';
protected $table = 'custom_field';
protected $fillable = ['slug', 'label', 'type', 'entity', 'field_options', 'status']; // Заполнить массив. Пример: ['label', 'slug', 'status']
public static function labels(): array
{
// Заполнить массив
// Пример: [
// 'label' => 'Заголовок',
// 'entity' => 'Сущность',
// 'slug' => 'Slug',
// 'status' => 'Статус',
// ]
return [
'slug' => 'Slug',
'label' => 'Название',
'type' => 'Тип',
'entity' => 'Сущность',
'field_options' => 'Опции поля',
'status' => 'Статус',
];
}
/**
* @return string[]
*/
public static function getStatus(): array
{
return [
self::DISABLE_STATUS => "Не активный",
self::ACTIVE_STATUS => "Активный",
];
}
/**
* @return string[]
*/
public static function getTypes(): array
{
return [
self::TYPE_STRING => 'Текст',
self::TYPE_SELECT => 'Список',
];
}
}