feat: 增强管理员权限管理,添加 RBAC 支持,更新 AdminUser 模型以处理角色和权限,更新登录接口返回权限信息,扩展数据库填充器以同步角色权限
This commit is contained in:
27
app/Models/AdminPermission.php
Normal file
27
app/Models/AdminPermission.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class AdminPermission extends Model
|
||||
{
|
||||
protected $table = 'admin_permissions';
|
||||
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'name',
|
||||
];
|
||||
|
||||
/** @return BelongsToMany<AdminRole, AdminPermission> */
|
||||
public function roles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
AdminRole::class,
|
||||
'admin_role_permissions',
|
||||
'permission_id',
|
||||
'role_id',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user