Files
fdesk/app/common/model/Role.php
T
mzl92 a6f2284f51 Merge branch 'feature/mzl_dev' into develop
# Conflicts:
#	app/common/controller/AuthController.php
#	app/common/logic/AuthLogic.php
#	app/common/model/User.php
#	app/controller/IndexController.php
#	app/functions.php
#	app/middleware/AuthCheck.php
#	app/view/index/qrcode.html
#	composer.json
#	composer.lock
#	config/middleware.php
#	config/route.php
#	config/whitelist.php
2025-07-11 15:21:00 +08:00

59 lines
1.2 KiB
PHP

<?php
namespace app\common\model;
use support\Model;
/**
* roles 角色表
* @property integer $id 角色ID(主键)
* @property string $name 角色名称
* @property string $desc 角色描述
* @property string $created_at
* @property string $updated_at
*/
class Role extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'roles';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
// 角色下所有用户
public function users()
{
return $this->belongsToMany(User::class, 'user_roles', 'role_id', 'user_id');
}
// 角色拥有的资源(权限点、菜单)
public function resources()
{
return $this->belongsToMany(Resource::class, 'role_resources', 'role_id', 'resource_id');
}
}