style: Laravel Pint 코드 포맷팅 적용

- PSR-12 스타일 가이드 준수
- 302개 파일 스타일 이슈 자동 수정
- 코드 로직 변경 없음 (포맷팅만)
This commit is contained in:
2025-11-06 17:45:49 +09:00
parent 48e76432ee
commit cc206fdbed
294 changed files with 4476 additions and 2561 deletions

View File

@@ -2,10 +2,10 @@
namespace App\Services;
use Illuminate\Support\Facades\DB;
use App\Models\Tenants\SettingFieldDef;
use App\Models\Tenants\TenantFieldSetting;
use App\Models\Tenants\TenantUserProfile;
use Illuminate\Support\Facades\DB;
class TenantUserProfileService
{
@@ -18,16 +18,19 @@ protected static function tenantId(): ?int
/** 효과값 필드(Enabled) 맵: field_key => [def, setting] */
protected static function effectiveFieldMap(int $tenantId): array
{
$defs = SettingFieldDef::all()->keyBy('field_key');
$defs = SettingFieldDef::all()->keyBy('field_key');
$settings = TenantFieldSetting::where('tenant_id', $tenantId)->get()->keyBy('field_key');
$map = [];
foreach ($defs as $key => $def) {
$s = $settings->get($key);
$enabled = $s ? (bool)$s->enabled : (bool)$def->is_core;
if (!$enabled) continue;
$enabled = $s ? (bool) $s->enabled : (bool) $def->is_core;
if (! $enabled) {
continue;
}
$map[$key] = ['def' => $def, 'setting' => $s];
}
return $map;
}
@@ -38,15 +41,15 @@ protected static function effectiveFieldMap(int $tenantId): array
public static function index(array $params = [])
{
$tenantId = self::tenantId();
if (!$tenantId) {
if (! $tenantId) {
return ['error' => '활성 테넌트가 없습니다.', 'code' => 400];
}
$per = (int)($params['per_page'] ?? $params['size'] ?? 20);
$q = TenantUserProfile::where('tenant_id', $tenantId)
$per = (int) ($params['per_page'] ?? $params['size'] ?? 20);
$q = TenantUserProfile::where('tenant_id', $tenantId)
->with(['user:id,name,email']);
if (!empty($params['q'])) {
if (! empty($params['q'])) {
$kw = $params['q'];
$q->where(function ($w) use ($kw) {
$w->where('display_name', 'like', "%{$kw}%")
@@ -54,7 +57,7 @@ public static function index(array $params = [])
});
}
$page = isset($params['page']) ? (int)$params['page'] : null;
$page = isset($params['page']) ? (int) $params['page'] : null;
$data = $q->orderByDesc('id')->paginate($per, ['*'], 'page', $page);
return $data;
@@ -66,10 +69,10 @@ public static function index(array $params = [])
public static function show(int $userId)
{
$tenantId = self::tenantId();
if (!$tenantId) {
if (! $tenantId) {
return ['error' => '활성 테넌트가 없습니다.', 'code' => 400];
}
if (!$userId) {
if (! $userId) {
return ['error' => 'userId가 올바르지 않습니다.', 'code' => 422];
}
@@ -78,7 +81,7 @@ public static function show(int $userId)
->with(['user:id,name,email'])
->first();
if (!$item) {
if (! $item) {
return ['error' => '프로필을 찾을 수 없습니다.', 'code' => 404];
}
@@ -92,27 +95,29 @@ public static function show(int $userId)
public static function update(int $userId, array $params = [])
{
$tenantId = self::tenantId();
if (!$tenantId) {
if (! $tenantId) {
return ['error' => '활성 테넌트가 없습니다.', 'code' => 400];
}
if (!$userId) {
if (! $userId) {
return ['error' => 'userId가 올바르지 않습니다.', 'code' => 422];
}
// (선택) 간단 유효성: 최소 1개 키 존재
if (empty($params) || !is_array($params)) {
if (empty($params) || ! is_array($params)) {
return ['error' => '수정할 항목이 없습니다.', 'code' => 422];
}
$fields = self::effectiveFieldMap($tenantId);
$fields = self::effectiveFieldMap($tenantId);
$profile = TenantUserProfile::firstOrCreate(['tenant_id' => $tenantId, 'user_id' => $userId]);
try {
DB::transaction(function () use ($fields, $profile, $params) {
foreach ($fields as $key => $meta) {
if (!array_key_exists($key, $params)) continue; // 입력이 없으면 스킵
if (! array_key_exists($key, $params)) {
continue;
} // 입력이 없으면 스킵
$def = $meta['def'];
$def = $meta['def'];
$value = $params[$key];
switch ($def->storage_area) {
@@ -124,7 +129,7 @@ public static function update(int $userId, array $params = [])
case 'tenant_profile_json':
$jsonKey = $def->storage_key ?: $key;
$extra = is_array($profile->json_extra) ? $profile->json_extra : (array) json_decode((string)$profile->json_extra, true);
$extra = is_array($profile->json_extra) ? $profile->json_extra : (array) json_decode((string) $profile->json_extra, true);
$extra[$jsonKey] = $value;
$profile->json_extra = $extra;
break;
@@ -155,11 +160,11 @@ public static function update(int $userId, array $params = [])
public static function me(array $params = [])
{
$tenantId = self::tenantId();
if (!$tenantId) {
if (! $tenantId) {
return ['error' => '활성 테넌트가 없습니다.', 'code' => 400];
}
$userId = auth()->id();
if (!$userId) {
if (! $userId) {
return ['error' => '인증 정보가 없습니다.', 'code' => 401];
}
@@ -179,13 +184,14 @@ public static function me(array $params = [])
public static function updateMe(array $params = [])
{
$tenantId = self::tenantId();
if (!$tenantId) {
if (! $tenantId) {
return ['error' => '활성 테넌트가 없습니다.', 'code' => 400];
}
$userId = auth()->id();
if (!$userId) {
if (! $userId) {
return ['error' => '인증 정보가 없습니다.', 'code' => 401];
}
return self::update($userId, $params);
}
}