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

@@ -17,6 +17,7 @@ protected static function tenantId(): ?int
protected static function actorId(): ?int
{
$user = app('api_user'); // 컨테이너에 주입된 인증 사용자(객체 or 배열)
return is_object($user) ? ($user->id ?? null) : ($user['id'] ?? null);
}
@@ -29,9 +30,15 @@ public static function index(array $params)
$q = Menu::query()->withShared($tenantId);
if (array_key_exists('parent_id', $params)) $q->where('parent_id', $params['parent_id']);
if (array_key_exists('is_active', $params)) $q->where('is_active', (int)$params['is_active']);
if (array_key_exists('hidden', $params)) $q->where('hidden', (int)$params['hidden']);
if (array_key_exists('parent_id', $params)) {
$q->where('parent_id', $params['parent_id']);
}
if (array_key_exists('is_active', $params)) {
$q->where('is_active', (int) $params['is_active']);
}
if (array_key_exists('hidden', $params)) {
$q->where('hidden', (int) $params['hidden']);
}
$q->orderBy('parent_id')->orderBy('sort_order');
@@ -44,10 +51,10 @@ public static function index(array $params)
*/
public static function show(array $params)
{
$id = (int)($params['id'] ?? 0);
$id = (int) ($params['id'] ?? 0);
$tenantId = self::tenantId();
if (!$id) {
if (! $id) {
return ['error' => 'id가 필요합니다.', 'code' => 400];
}
@@ -55,6 +62,7 @@ public static function show(array $params)
if (empty($res['data'])) {
return ['error' => 'Menu not found', 'code' => 404];
}
return $res;
}
@@ -64,18 +72,18 @@ public static function show(array $params)
public static function store(array $params)
{
$tenantId = self::tenantId();
$userId = self::actorId();
$userId = self::actorId();
$v = Validator::make($params, [
'parent_id' => ['nullable','integer'],
'name' => ['required','string','max:100'],
'url' => ['nullable','string','max:255'],
'is_active' => ['nullable','boolean'],
'sort_order' => ['nullable','integer'],
'hidden' => ['nullable','boolean'],
'is_external' => ['nullable','boolean'],
'external_url' => ['nullable','string','max:255'],
'icon' => ['nullable','string','max:50'],
'parent_id' => ['nullable', 'integer'],
'name' => ['required', 'string', 'max:100'],
'url' => ['nullable', 'string', 'max:255'],
'is_active' => ['nullable', 'boolean'],
'sort_order' => ['nullable', 'integer'],
'hidden' => ['nullable', 'boolean'],
'is_external' => ['nullable', 'boolean'],
'external_url' => ['nullable', 'string', 'max:255'],
'icon' => ['nullable', 'string', 'max:50'],
]);
if ($v->fails()) {
@@ -83,19 +91,19 @@ public static function store(array $params)
}
$data = $v->validated();
$menu = new Menu();
$menu->tenant_id = $tenantId;
$menu->parent_id = $data['parent_id'] ?? null;
$menu->name = $data['name'];
$menu->url = $data['url'] ?? null;
$menu->is_active = (int)($data['is_active'] ?? 1);
$menu->sort_order = (int)($data['sort_order'] ?? 0);
$menu->hidden = (int)($data['hidden'] ?? 0);
$menu->is_external = (int)($data['is_external'] ?? 0);
$menu = new Menu;
$menu->tenant_id = $tenantId;
$menu->parent_id = $data['parent_id'] ?? null;
$menu->name = $data['name'];
$menu->url = $data['url'] ?? null;
$menu->is_active = (int) ($data['is_active'] ?? 1);
$menu->sort_order = (int) ($data['sort_order'] ?? 0);
$menu->hidden = (int) ($data['hidden'] ?? 0);
$menu->is_external = (int) ($data['is_external'] ?? 0);
$menu->external_url = $data['external_url'] ?? null;
$menu->icon = $data['icon'] ?? null;
$menu->created_by = $userId;
$menu->updated_by = $userId;
$menu->icon = $data['icon'] ?? null;
$menu->created_by = $userId;
$menu->updated_by = $userId;
$menu->save();
// 생성 결과를 그대로 전달
@@ -107,24 +115,24 @@ public static function store(array $params)
*/
public static function update(array $params)
{
$id = (int)($params['id'] ?? 0);
$id = (int) ($params['id'] ?? 0);
$tenantId = self::tenantId();
$userId = self::actorId();
$userId = self::actorId();
if (!$id) {
if (! $id) {
return ['error' => 'id가 필요합니다.', 'code' => 400];
}
$v = Validator::make($params, [
'parent_id' => ['nullable','integer'],
'name' => ['nullable','string','max:100'],
'url' => ['nullable','string','max:255'],
'is_active' => ['nullable','boolean'],
'sort_order' => ['nullable','integer'],
'hidden' => ['nullable','boolean'],
'is_external' => ['nullable','boolean'],
'external_url' => ['nullable','string','max:255'],
'icon' => ['nullable','string','max:50'],
'parent_id' => ['nullable', 'integer'],
'name' => ['nullable', 'string', 'max:100'],
'url' => ['nullable', 'string', 'max:255'],
'is_active' => ['nullable', 'boolean'],
'sort_order' => ['nullable', 'integer'],
'hidden' => ['nullable', 'boolean'],
'is_external' => ['nullable', 'boolean'],
'external_url' => ['nullable', 'string', 'max:255'],
'icon' => ['nullable', 'string', 'max:50'],
]);
if ($v->fails()) {
@@ -133,14 +141,14 @@ public static function update(array $params)
$data = $v->validated();
$menu = Menu::withShared($tenantId)->where('id', $id)->first();
if (!$menu) {
if (! $menu) {
return ['error' => 'Menu not found', 'code' => 404];
}
$update = Arr::only($data, [
'parent_id','name','url','is_active','sort_order','hidden','is_external','external_url','icon'
'parent_id', 'name', 'url', 'is_active', 'sort_order', 'hidden', 'is_external', 'external_url', 'icon',
]);
$update = array_filter($update, fn($v) => !is_null($v));
$update = array_filter($update, fn ($v) => ! is_null($v));
if (empty($update)) {
return ['error' => '수정할 데이터가 없습니다.', 'code' => 400];
@@ -157,16 +165,16 @@ public static function update(array $params)
*/
public static function destroy(array $params)
{
$id = (int)($params['id'] ?? 0);
$id = (int) ($params['id'] ?? 0);
$tenantId = self::tenantId();
$userId = self::actorId();
$userId = self::actorId();
if (!$id) {
if (! $id) {
return ['error' => 'id가 필요합니다.', 'code' => 400];
}
$menu = Menu::withShared($tenantId)->where('id', $id)->first();
if (!$menu) {
if (! $menu) {
return ['error' => 'Menu not found', 'code' => 404];
}
@@ -183,18 +191,20 @@ public static function destroy(array $params)
*/
public static function reorder(array $params)
{
if (!is_array($params) || empty($params)) {
if (! is_array($params) || empty($params)) {
return ['error' => '유효한 정렬 목록이 필요합니다.', 'code' => 422];
}
$tenantId = self::tenantId();
DB::transaction(function () use ($params, $tenantId) {
foreach ($params as $it) {
if (!isset($it['id'], $it['sort_order'])) continue;
if (! isset($it['id'], $it['sort_order'])) {
continue;
}
$menu = Menu::withShared($tenantId)->find((int)$it['id']);
$menu = Menu::withShared($tenantId)->find((int) $it['id']);
if ($menu) {
$menu->sort_order = (int)$it['sort_order'];
$menu->sort_order = (int) $it['sort_order'];
$menu->save();
}
}
@@ -208,26 +218,26 @@ public static function reorder(array $params)
*/
public static function toggle(array $params)
{
$id = (int)($params['id'] ?? 0);
$id = (int) ($params['id'] ?? 0);
$tenantId = self::tenantId();
$userId = self::actorId();
$userId = self::actorId();
if (!$id) {
if (! $id) {
return ['error' => 'id가 필요합니다.', 'code' => 400];
}
$payload = array_filter([
'is_active' => array_key_exists('is_active', $params) ? (int)$params['is_active'] : null,
'hidden' => array_key_exists('hidden', $params) ? (int)$params['hidden'] : null,
'is_external' => array_key_exists('is_external', $params) ? (int)$params['is_external'] : null,
], fn($v) => !is_null($v));
'is_active' => array_key_exists('is_active', $params) ? (int) $params['is_active'] : null,
'hidden' => array_key_exists('hidden', $params) ? (int) $params['hidden'] : null,
'is_external' => array_key_exists('is_external', $params) ? (int) $params['is_external'] : null,
], fn ($v) => ! is_null($v));
if (empty($payload)) {
return ['error' => '변경할 필드가 없습니다.', 'code' => 422];
}
$menu = Menu::withShared($tenantId)->find($id);
if (!$menu) {
if (! $menu) {
return ['error' => 'Menu not found', 'code' => 404];
}