feat(API): 역할/권한 관리 API 개선
- RoleController: 역할 CRUD API 개선 - RolePermissionController: 역할별 권한 설정 API 추가 - RoleService/RolePermissionService: 비즈니스 로직 분리 - Role 모델: is_hidden 필드 추가 (시스템 역할 숨김) - 역할 숨김 마이그레이션 추가 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,29 +5,83 @@
|
||||
use App\Models\Commons\IdeHelperRole;
|
||||
use App\Models\Members\UserRole;
|
||||
use App\Models\Tenants\Tenant;
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* @mixin IdeHelperRole
|
||||
*/
|
||||
class Role extends Model
|
||||
{
|
||||
use BelongsToTenant, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id', 'name', 'description',
|
||||
'tenant_id',
|
||||
'name',
|
||||
'guard_name',
|
||||
'description',
|
||||
'is_hidden',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_hidden' => 'boolean',
|
||||
'tenant_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 관계: 메뉴 권한 (다대다)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관계: 권한 (role_has_permissions 테이블 통해)
|
||||
*/
|
||||
public function permissions()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
Permission::class,
|
||||
'role_has_permissions',
|
||||
'role_id',
|
||||
'permission_id'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 스코프: 공개된 역할만
|
||||
*/
|
||||
public function scopeVisible($query)
|
||||
{
|
||||
return $query->where('is_hidden', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 스코프: 숨겨진 역할만
|
||||
*/
|
||||
public function scopeHidden($query)
|
||||
{
|
||||
return $query->where('is_hidden', true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user