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,19 +2,18 @@
namespace App\Services;
use App\Models\Commons\Category;
use App\Models\Commons\CategoryTemplate;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use App\Models\Commons\CategoryTemplate;
use App\Models\Commons\Category;
use App\Models\Commons\CategoryField;
class CategoryTemplateService extends Service
{
public function index(int $categoryId, array $params)
{
$tenantId = $this->tenantId();
$size = (int)($params['size'] ?? 20);
$size = (int) ($params['size'] ?? 20);
return CategoryTemplate::query()
->where('tenant_id', $tenantId)
@@ -26,14 +25,14 @@ public function index(int $categoryId, array $params)
public function store(int $categoryId, array $data)
{
$tenantId = $this->tenantId();
$userId = $this->apiUserId();
$userId = $this->apiUserId();
$this->assertCategoryExists($tenantId, $categoryId);
$v = Validator::make($data, [
'version_no' => 'required|integer|min:1',
'version_no' => 'required|integer|min:1',
'template_json' => 'required|json',
'applied_at' => 'required|date',
'remarks' => 'nullable|string|max:255',
'applied_at' => 'required|date',
'remarks' => 'nullable|string|max:255',
]);
$payload = $v->validate();
@@ -46,9 +45,9 @@ public function store(int $categoryId, array $data)
throw new BadRequestHttpException(__('error.duplicate_key')); // version_no 중복
}
$payload['tenant_id'] = $tenantId;
$payload['tenant_id'] = $tenantId;
$payload['category_id'] = $categoryId;
$payload['created_by'] = $userId;
$payload['created_by'] = $userId;
return CategoryTemplate::create($payload);
}
@@ -61,30 +60,36 @@ public function show(int $tplId)
->where('tenant_id', $tenantId)
->find($tplId);
if (!$tpl) throw new BadRequestHttpException(__('error.not_found'));
if (! $tpl) {
throw new BadRequestHttpException(__('error.not_found'));
}
return $tpl;
}
public function update(int $tplId, array $data)
{
$tenantId = $this->tenantId();
$userId = $this->apiUserId();
$userId = $this->apiUserId();
$tpl = CategoryTemplate::query()
->where('tenant_id', $tenantId)
->find($tplId);
if (!$tpl) throw new BadRequestHttpException(__('error.not_found'));
if (! $tpl) {
throw new BadRequestHttpException(__('error.not_found'));
}
$v = Validator::make($data, [
'template_json' => 'nullable|json',
'applied_at' => 'nullable|date',
'remarks' => 'nullable|string|max:255',
'applied_at' => 'nullable|date',
'remarks' => 'nullable|string|max:255',
]);
$payload = $v->validate();
$payload['updated_by'] = $userId;
$tpl->update($payload);
return $tpl->refresh();
}
@@ -96,7 +101,9 @@ public function destroy(int $tplId): void
->where('tenant_id', $tenantId)
->find($tplId);
if (!$tpl) throw new BadRequestHttpException(__('error.not_found'));
if (! $tpl) {
throw new BadRequestHttpException(__('error.not_found'));
}
$tpl->delete();
}
@@ -108,16 +115,18 @@ public function destroy(int $tplId): void
public function apply(int $categoryId, int $tplId): void
{
$tenantId = $this->tenantId();
$userId = $this->apiUserId();
$userId = $this->apiUserId();
$tpl = CategoryTemplate::query()
->where('tenant_id', $tenantId)
->where('category_id', $categoryId)
->find($tplId);
if (!$tpl) throw new BadRequestHttpException(__('error.not_found'));
if (! $tpl) {
throw new BadRequestHttpException(__('error.not_found'));
}
DB::transaction(function () use ($tenantId, $userId, $categoryId, $tpl) {
DB::transaction(function () {
// 1) categories 테이블에 활성 버전 반영(컬럼이 있다면)
// Category::where('tenant_id', $tenantId)->where('id', $categoryId)->update([
// 'active_template_version' => $tpl->version_no,
@@ -143,12 +152,15 @@ public function preview(int $categoryId, int $tplId): array
->where('category_id', $categoryId)
->find($tplId);
if (!$tpl) throw new BadRequestHttpException(__('error.not_found'));
if (! $tpl) {
throw new BadRequestHttpException(__('error.not_found'));
}
$json = json_decode($tpl->template_json, true);
if (!is_array($json)) {
if (! is_array($json)) {
throw new BadRequestHttpException(__('error.invalid_payload'));
}
// 프론트 렌더링 편의 구조로 가공 가능
return $json;
}
@@ -165,7 +177,9 @@ public function diff(int $categoryId, int $a, int $b): array
->where('tenant_id', $tenantId)->where('category_id', $categoryId)
->where('version_no', $b)->first();
if (!$aTpl || !$bTpl) throw new BadRequestHttpException(__('error.not_found'));
if (! $aTpl || ! $bTpl) {
throw new BadRequestHttpException(__('error.not_found'));
}
$aj = json_decode($aTpl->template_json, true) ?: [];
$bj = json_decode($bTpl->template_json, true) ?: [];
@@ -175,7 +189,7 @@ public function diff(int $categoryId, int $a, int $b): array
$bKeys = collect($bj['fields'] ?? [])->pluck('key')->all();
return [
'added' => array_values(array_diff($bKeys, $aKeys)),
'added' => array_values(array_diff($bKeys, $aKeys)),
'removed' => array_values(array_diff($aKeys, $bKeys)),
// 변경(diff in detail)은 정책에 맞게 확장
];
@@ -187,7 +201,7 @@ private function assertCategoryExists(int $tenantId, int $categoryId): void
->where('tenant_id', $tenantId)
->where('id', $categoryId)
->exists();
if (!$exists) {
if (! $exists) {
throw new BadRequestHttpException(__('error.category_not_found'));
}
}