feat: [users] 사용자 관리에 직급/직책 입력 UI 추가
- 사용자 수정/생성 화면에 직급(position_key), 직책(job_title_key) 선택 필드 추가 - HR 사원관리의 position-add-modal 재사용 ([+] 버튼으로 새 직급/직책 추가) - UserService에서 tenant_user_profiles 테이블에 저장 (updateOrInsert) - UpdateUserRequest, StoreUserRequest에 validation 규칙 추가
This commit is contained in:
@@ -3,11 +3,13 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Department;
|
||||
use App\Models\HR\Position;
|
||||
use App\Models\Role;
|
||||
use App\Models\Tenants\Tenant;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class UserController extends Controller
|
||||
@@ -40,6 +42,10 @@ public function create(): View
|
||||
$roles = $tenantId ? Role::where('tenant_id', $tenantId)->orderBy('name')->get() : collect();
|
||||
$departments = $tenantId ? Department::where('tenant_id', $tenantId)->where('is_active', true)->orderBy('name')->get() : collect();
|
||||
|
||||
// 직급/직책 목록
|
||||
$ranks = $tenantId ? Position::forTenant($tenantId)->ranks()->where('is_active', true)->ordered()->get() : collect();
|
||||
$titles = $tenantId ? Position::forTenant($tenantId)->titles()->where('is_active', true)->ordered()->get() : collect();
|
||||
|
||||
// 본사 테넌트 여부 확인 (본사: 이메일 인증, 그 외: 비밀번호 직접 입력)
|
||||
$isHQ = false;
|
||||
if ($tenantId) {
|
||||
@@ -47,7 +53,7 @@ public function create(): View
|
||||
$isHQ = $tenant?->tenant_type === 'HQ';
|
||||
}
|
||||
|
||||
return view('users.create', compact('roles', 'departments', 'isHQ'));
|
||||
return view('users.create', compact('roles', 'departments', 'isHQ', 'ranks', 'titles'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,6 +82,19 @@ public function edit(int $id): View
|
||||
$userRoleIds = $tenantId ? $user->userRoles()->where('tenant_id', $tenantId)->pluck('role_id')->toArray() : [];
|
||||
$userDepartmentIds = $tenantId ? $user->departmentUsers()->where('tenant_id', $tenantId)->pluck('department_id')->toArray() : [];
|
||||
|
||||
return view('users.edit', compact('user', 'roles', 'departments', 'userRoleIds', 'userDepartmentIds'));
|
||||
// 직급/직책 목록
|
||||
$ranks = $tenantId ? Position::forTenant($tenantId)->ranks()->where('is_active', true)->ordered()->get() : collect();
|
||||
$titles = $tenantId ? Position::forTenant($tenantId)->titles()->where('is_active', true)->ordered()->get() : collect();
|
||||
|
||||
// tenant_user_profiles에서 현재 position_key, job_title_key 조회
|
||||
$profile = $tenantId
|
||||
? DB::table('tenant_user_profiles')
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('user_id', $user->id)
|
||||
->first(['position_key', 'job_title_key'])
|
||||
: null;
|
||||
|
||||
return view('users.edit', compact('user', 'roles', 'departments', 'userRoleIds', 'userDepartmentIds',
|
||||
'ranks', 'titles', 'profile'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user