You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
857 B
38 lines
857 B
|
1 week ago
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||
|
|
|
||
|
|
class Role extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = [
|
||
|
|
'code',
|
||
|
|
'name',
|
||
|
|
'remark',
|
||
|
|
'sort',
|
||
|
|
'status',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'sort' => 'integer',
|
||
|
|
'status' => 'integer',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function permissions(): BelongsToMany
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(Permission::class, 'role_permissions', 'role_id', 'permission_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function menus(): BelongsToMany
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(Menu::class, 'role_menus', 'role_id', 'menu_id')->withPivot([]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function adminUsers(): BelongsToMany
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(AdminUser::class, 'admin_user_roles', 'role_id', 'admin_user_id');
|
||
|
|
}
|
||
|
|
}
|