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

@@ -14,11 +14,11 @@ public function index(array $params)
{
$tenantId = $this->tenantId();
$page = (int)($params['page'] ?? 1);
$size = (int)($params['size'] ?? 20);
$q = trim((string)($params['q'] ?? ''));
$page = (int) ($params['page'] ?? 1);
$size = (int) ($params['size'] ?? 20);
$q = trim((string) ($params['q'] ?? ''));
$group = $params['group'] ?? null;
$only = $params['only_active'] ?? null;
$only = $params['only_active'] ?? null;
$query = Classification::query()->where('tenant_id', $tenantId);
@@ -28,11 +28,11 @@ public function index(array $params)
->orWhere('code', 'like', "%{$q}%");
});
}
if (!is_null($group) && $group !== '') {
if (! is_null($group) && $group !== '') {
$query->where('group', $group);
}
if (!is_null($only)) {
$query->where('is_active', (int)!!$only);
if (! is_null($only)) {
$query->where('is_active', (int) (bool) $only);
}
$query->orderBy('group')->orderBy('code')->orderBy('id');
@@ -45,7 +45,10 @@ public function show(int $id)
{
$tenantId = $this->tenantId();
$row = Classification::where('tenant_id', $tenantId)->find($id);
if (!$row) throw new NotFoundHttpException(__('error.not_found'));
if (! $row) {
throw new NotFoundHttpException(__('error.not_found'));
}
return $row;
}
@@ -53,26 +56,30 @@ public function show(int $id)
public function store(array $params)
{
$tenantId = $this->tenantId();
$uid = $this->apiUserId();
$uid = $this->apiUserId();
$v = Validator::make($params, [
'group' => 'required|string|max:50',
'code' => 'required|string|max:50',
'name' => 'required|string|max:100',
'is_active' => 'nullable|boolean',
'group' => 'required|string|max:50',
'code' => 'required|string|max:50',
'name' => 'required|string|max:100',
'is_active' => 'nullable|boolean',
]);
if ($v->fails()) throw new BadRequestHttpException($v->errors()->first());
if ($v->fails()) {
throw new BadRequestHttpException($v->errors()->first());
}
// 그룹 내 코드 중복 체크(tenant 기준)
$data = $v->validated();
$exists = Classification::where('tenant_id', $tenantId)
->where('group', $data['group'])
->where('code', $data['code'])
->where('code', $data['code'])
->exists();
if ($exists) throw new BadRequestHttpException(__('validation.unique', ['attribute' => 'code']));
if ($exists) {
throw new BadRequestHttpException(__('validation.unique', ['attribute' => 'code']));
}
$data['tenant_id'] = $tenantId;
$data['is_active'] = (int)($data['is_active'] ?? 1);
$data['is_active'] = (int) ($data['is_active'] ?? 1);
return Classification::create($data);
}
@@ -83,29 +90,36 @@ public function update(int $id, array $params)
$tenantId = $this->tenantId();
$row = Classification::where('tenant_id', $tenantId)->find($id);
if (!$row) throw new NotFoundHttpException(__('error.not_found'));
if (! $row) {
throw new NotFoundHttpException(__('error.not_found'));
}
$v = Validator::make($params, [
'group' => 'sometimes|required|string|max:50',
'code' => 'sometimes|required|string|max:50',
'name' => 'sometimes|required|string|max:100',
'is_active' => 'nullable|boolean',
'group' => 'sometimes|required|string|max:50',
'code' => 'sometimes|required|string|max:50',
'name' => 'sometimes|required|string|max:100',
'is_active' => 'nullable|boolean',
]);
if ($v->fails()) throw new BadRequestHttpException($v->errors()->first());
if ($v->fails()) {
throw new BadRequestHttpException($v->errors()->first());
}
$payload = $v->validated();
// group 또는 code 변경 시 유니크 검사
$newGroup = $payload['group'] ?? $row->group;
$newCode = $payload['code'] ?? $row->code;
$newCode = $payload['code'] ?? $row->code;
$dupe = Classification::where('tenant_id', $tenantId)
->where('group', $newGroup)
->where('code', $newCode)
->where('code', $newCode)
->where('id', '!=', $row->id)
->exists();
if ($dupe) throw new BadRequestHttpException(__('validation.unique', ['attribute' => 'code']));
if ($dupe) {
throw new BadRequestHttpException(__('validation.unique', ['attribute' => 'code']));
}
$row->update($payload);
return $row->refresh();
}
@@ -115,9 +129,12 @@ public function destroy(int $id)
$tenantId = $this->tenantId();
$row = Classification::where('tenant_id', $tenantId)->find($id);
if (!$row) throw new NotFoundHttpException(__('error.not_found'));
if (! $row) {
throw new NotFoundHttpException(__('error.not_found'));
}
$row->delete();
return 'success';
}
}