fix : 카테고리, 제품등록, BOM등록 API (일부 개발 - BOM 추가 작업 필요)

This commit is contained in:
2025-08-25 17:46:34 +09:00
parent 6307fdc1dc
commit 52bf8527e2
16 changed files with 2591 additions and 80 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Services;
use Illuminate\Support\Carbon;
use App\Models\Commons\CategoryLog;
class CategoryLogService extends Service
{
public function index(int $categoryId, array $params)
{
$tenantId = $this->tenantId();
$size = (int)($params['size'] ?? 20);
$action = $params['action'] ?? null; // insert|update|delete
$from = $params['from'] ?? null; // Y-m-d
$to = $params['to'] ?? null;
$q = CategoryLog::query()
->where('tenant_id', $tenantId)
->where('category_id', $categoryId)
->orderByDesc('changed_at');
if ($action) $q->where('action', $action);
if ($from) $q->whereDate('changed_at', '>=', Carbon::parse($from)->toDateString());
if ($to) $q->whereDate('changed_at', '<=', Carbon::parse($to)->toDateString());
return $q->paginate($size);
}
public function show(int $logId)
{
$tenantId = $this->tenantId();
$log = CategoryLog::query()
->where('tenant_id', $tenantId)
->find($logId);
if (!$log) throw new BadRequestHttpException(__('error.not_found'));
return $log;
}
}