mirror of https://gitee.com/karson/fastadmin.git
40 lines
905 B
PHP
40 lines
905 B
PHP
<?php
|
|
|
|
namespace app\admin\model;
|
|
|
|
use think\Model;
|
|
use think\Session;
|
|
|
|
class Page extends Model
|
|
{
|
|
// 表名
|
|
protected $name = 'page';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'int';
|
|
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = 'updatetime';
|
|
|
|
|
|
/**
|
|
* 根据后台入口和管理员等级来自动读取
|
|
* 1, 如果是从站点后台登录,所有管理员只能读取本站点信息
|
|
* 2, 如果是从总后台登录,管理员读取属于自己的站点的信息,超级管理员无限制
|
|
*/
|
|
protected function base($query)
|
|
{
|
|
if (Session::has("user_site_id")) {
|
|
$query->where('site_id', Session::get("user_site_id"));
|
|
}
|
|
}
|
|
|
|
public function Sites()
|
|
{
|
|
return $this->belongsTo('Sites', 'site_id')->field('id,name');
|
|
}
|
|
|
|
|
|
}
|