server/app/Model/SystemConfig.php

55 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $config_id
* @property string $config_name
* @property string $config_key
* @property string $config_value
* @property string $remark
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class SystemConfig extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'system_config';
protected string $primaryKey = 'config_id';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['config_id' => 'integer'];
public static function list(array $param)
{
$model = self::query();
if (isset($param['config_name']) && $param['config_name'] != '') {
$model = $model->where('config_name', "like", "%{$param['config_name']}%");
}
if (isset($param['config_key']) && $param['config_key'] != '') {
$model = $model->where('config_key', "like", "%{$param['config_key']}%");
}
return $model->orderByDesc("config_id")
->select(["config_id", "config_name", "config_key", "config_value", "remark", "create_time", "update_time"])
->paginate((int)$param['limit']);
}
public static function options()
{
return self::select(["config_id", "config_name"])->get()->toArray();
}
}