fix : 부서관리 기능 수정
- Route, Controller, Service, Swagger, DB 수정 - 모델 위치 이동
This commit is contained in:
40
app/Models/Permissions/PermissionOverride.php
Normal file
40
app/Models/Permissions/PermissionOverride.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Permissions;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Permission\Models\Permission as SpatiePermission;
|
||||
|
||||
class PermissionOverride extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'permission_overrides';
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $casts = [
|
||||
'tenant_id' => 'int',
|
||||
'model_id' => 'int',
|
||||
'permission_id' => 'int',
|
||||
'effect' => 'int', // 1=ALLOW, -1=DENY
|
||||
'effective_from' => 'datetime',
|
||||
'effective_to' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* 예외가 걸린 주체(User, Department 등)
|
||||
* model_type, model_id를 사용하는 morphTo
|
||||
*/
|
||||
public function model()
|
||||
{
|
||||
// morphTo(relationshipName, type, id)
|
||||
return $this->morphTo('model', 'model_type', 'model_id');
|
||||
}
|
||||
|
||||
/** 연결된 Spatie Permission */
|
||||
public function permission()
|
||||
{
|
||||
return $this->belongsTo(SpatiePermission::class, 'permission_id');
|
||||
}
|
||||
}
|
||||
33
app/Models/Permissions/Role.php
Normal file
33
app/Models/Permissions/Role.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Permissions;
|
||||
|
||||
use App\Models\Commons\IdeHelperRole;
|
||||
use App\Models\Members\UserRole;
|
||||
use App\Models\Tenants\Tenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @mixin IdeHelperRole
|
||||
*/
|
||||
class Role extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'tenant_id', 'name', 'description'
|
||||
];
|
||||
|
||||
public function menuPermissions()
|
||||
{
|
||||
return $this->hasMany(RoleMenuPermission::class, 'role_id');
|
||||
}
|
||||
|
||||
public function tenant()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
public function userRoles()
|
||||
{
|
||||
return $this->hasMany(UserRole::class);
|
||||
}
|
||||
}
|
||||
27
app/Models/Permissions/RoleMenuPermission.php
Normal file
27
app/Models/Permissions/RoleMenuPermission.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Permissions;
|
||||
|
||||
use App\Models\Commons\IdeHelperRoleMenuPermission;
|
||||
use App\Models\Commons\Menu;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @mixin IdeHelperRoleMenuPermission
|
||||
*/
|
||||
class RoleMenuPermission extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'role_id', 'menu_id', 'access', 'read', 'write', 'export', 'approve'
|
||||
];
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo(Role::class, 'role_id');
|
||||
}
|
||||
|
||||
public function menu()
|
||||
{
|
||||
return $this->belongsTo(Menu::class, 'menu_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user