- RoleService, RoleController (Blade/API) 생성 - 역할 CRUD 기능 완성 (목록/생성/수정/삭제) - FormRequest 검증 (StoreRoleRequest, UpdateRoleRequest) - HTMX 패턴 적용 (index, create, edit) - 권한 선택 UI (체크박스, 전체 선택/해제) - Tenant Selector 통합 - 레이아웃 패턴 문서화 (LAYOUT_PATTERN.md) - Sidebar 메뉴에 역할 관리 추가 - Pagination partial 컴포넌트 추가 - Tenants 레이아웃 100% 폭으로 통일 주요 수정: - UpdateRoleRequest 라우트 파라미터 수정 (role → id) - RoleController permissions 조회 시 description 제거 - Conditional tenant filtering 적용
57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Spatie\Permission\Models\Permission;
|
|
|
|
class Role extends Model
|
|
{
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'name',
|
|
'description',
|
|
'guard_name',
|
|
];
|
|
|
|
protected $casts = [
|
|
'tenant_id' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 관계: 테넌트
|
|
*/
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class, 'tenant_id');
|
|
}
|
|
|
|
/**
|
|
* 관계: 권한 (다대다)
|
|
*/
|
|
public function permissions(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
Permission::class,
|
|
'role_has_permissions',
|
|
'role_id',
|
|
'permission_id'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 관계: 사용자 (다대다)
|
|
*/
|
|
public function users(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
User::class,
|
|
'model_has_roles',
|
|
'role_id',
|
|
'model_id'
|
|
)->wherePivot('model_type', User::class);
|
|
}
|
|
} |