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.
32 lines
706 B
32 lines
706 B
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
class Role extends SoftDeletesModel
|
|
{
|
|
|
|
protected $table = "roles";
|
|
|
|
public function scopeOfGuard($query, $guard)
|
|
{
|
|
return $query->where("guard_name", $guard);
|
|
}
|
|
|
|
public function permissions()
|
|
{
|
|
return $this->belongsToMany(Permission::class, 'role_has_permissions', "role_id", "permission_id")->withPivot('auth_node_tags');
|
|
}
|
|
|
|
public function admin()
|
|
{
|
|
return $this->belongsToMany(Admin::class, 'model_has_roles', 'role_id', 'model_id')->where('model_type', 'App\Models\Admin');
|
|
}
|
|
|
|
public function roleHasPermissions()
|
|
{
|
|
return $this->hasMany(RoleHasPermission::class, 'role_id', 'id');
|
|
}
|
|
|
|
|
|
}
|