72 lines
1.7 KiB
PHP
72 lines
1.7 KiB
PHP
<?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 => 'Список',
|
||
];
|
||
}
|
||
|
||
} |