blog/app/model/Role.php

39 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2024-06-08 15:54:41 +08:00
<?php
namespace app\model;
use think\Model;
class Role extends Model
{
protected $table = 'eb_role';
protected $primaryKey = 'id';
public $timestamps = false;
/**
* User: 高军
* Date: 2024/5/8
* QQ: 2926804347
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* Notes:
*/
public function allList():array
{
$info = $this->select()->toArray();
if ($info) return show(true, '获取成功', ['rows' => $info]);
return show(false, '暂无数据');
}
public function saveData(array $param):array
{
if (!empty($param['id'])) {
$info = $this->update($param);
}else{
$param['create_time'] = date('Y-m-d H:i:s', time());
$info = $this::create($param);
}
if ($info) return show(true, '保存成功');
return show(false, '保存失败,请重试');
}
}