server/app/Model/Dict.php

54 lines
1.4 KiB
PHP

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