Files
dafuweng-saiadmin6.x/server/app/dice/model/config/DiceConfig.php

84 lines
1.9 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
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\dice\model\config;
use plugin\saiadmin\basic\eloquent\BaseModel;
/**
* 摇色子配置模型
*
* dice_config 摇色子配置
*
* @property $id ID
* @property $name 配置名称
* @property $group 分组
* @property $title 标题
* @property $title_en 标题(英文)
* @property $value 值
* @property $value_en 值(英文)
* @property $create_time 创建时间
* @property $update_time 修改时间
*/
class DiceConfig extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $primaryKey = 'id';
/**
* 数据库表名称
* @var string
*/
protected $table = 'dice_config';
/**
* 是否自动维护 create_time / update_time继承基类 CREATED_AT / UPDATED_AT
* @var bool
*/
public $timestamps = true;
/**
* 属性转换
*/
protected function casts(): array
{
return array_merge(parent::casts(), [
]);
}
/**
* 配置名称 搜索
*/
public function searchNameAttr($query, $value)
{
$query->where('name', 'like', '%'.$value.'%');
}
/**
* 分组 搜索
*/
public function searchGroupAttr($query, $value)
{
if ($value === '' || $value === null) {
return;
}
$query->where('group', '=', $value);
}
/**
* 标题 搜索
*/
public function searchTitleAttr($query, $value)
{
if ($value === '' || $value === null) {
return;
}
$query->where('title', 'like', '%' . $value . '%');
}
}