From d943c3a2402fc0580c42073058f853a80ed5abf0 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sat, 1 Aug 2026 22:51:24 +0700 Subject: [PATCH] refactor: standardize pagination parameters and improve code formatting across multiple services --- app/Services/Admin/Finance/CashAccountService.php | 2 +- app/Services/Admin/Finance/EmployeeAdvanceService.php | 2 +- app/Services/Admin/Finance/ExpenseService.php | 2 +- app/Services/Admin/Finance/PayrollPeriodService.php | 2 +- app/Services/Admin/HR/EmployeeService.php | 2 +- app/Services/Admin/HR/LeaveRequestService.php | 2 +- app/Services/Admin/Master/CategoryService.php | 2 +- app/Services/Admin/Master/CustomerService.php | 2 +- app/Services/Admin/Master/Product/ProductService.php | 8 +++++--- app/Services/Admin/Master/SupplierService.php | 2 +- app/Services/Admin/Settings/RoleService.php | 2 +- 11 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/Services/Admin/Finance/CashAccountService.php b/app/Services/Admin/Finance/CashAccountService.php index 9ebcc47..52220c1 100644 --- a/app/Services/Admin/Finance/CashAccountService.php +++ b/app/Services/Admin/Finance/CashAccountService.php @@ -46,7 +46,7 @@ public function getAllTransactions(array $filters = []): Collection ->map(fn (CashTransaction $transaction) => $this->formatTransaction($transaction)); } - public function paginatedTransactions(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator + public function paginatedTransactions(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator { $cashAccount = $this->get(); diff --git a/app/Services/Admin/Finance/EmployeeAdvanceService.php b/app/Services/Admin/Finance/EmployeeAdvanceService.php index abb3f8a..4a6fee3 100644 --- a/app/Services/Admin/Finance/EmployeeAdvanceService.php +++ b/app/Services/Admin/Finance/EmployeeAdvanceService.php @@ -23,7 +23,7 @@ public function getAll(): Collection ->get(); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator { return EmployeeAdvance::query() ->select('id', 'employee_id', 'amount', 'paid_amount', 'description', 'due_date', 'status', 'created_at') diff --git a/app/Services/Admin/Finance/ExpenseService.php b/app/Services/Admin/Finance/ExpenseService.php index 898dc26..56679dc 100644 --- a/app/Services/Admin/Finance/ExpenseService.php +++ b/app/Services/Admin/Finance/ExpenseService.php @@ -32,7 +32,7 @@ public function getAll(): Collection ->map(fn (Expense $expense) => $this->formatExpense($expense)); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator { $paginator = Expense::query() ->select('id', 'created_by_id', 'amount', 'description', 'created_at') diff --git a/app/Services/Admin/Finance/PayrollPeriodService.php b/app/Services/Admin/Finance/PayrollPeriodService.php index ee15eff..409fd59 100644 --- a/app/Services/Admin/Finance/PayrollPeriodService.php +++ b/app/Services/Admin/Finance/PayrollPeriodService.php @@ -35,7 +35,7 @@ public function getAll(): Collection ->get(); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator { return PayrollPeriod::query() ->select('id', 'year', 'month', 'status', 'closed_at', 'created_at') diff --git a/app/Services/Admin/HR/EmployeeService.php b/app/Services/Admin/HR/EmployeeService.php index 8151307..a19e996 100644 --- a/app/Services/Admin/HR/EmployeeService.php +++ b/app/Services/Admin/HR/EmployeeService.php @@ -24,7 +24,7 @@ public function getAll(array $filters = []): Collection ->get(); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator { return User::query() ->select('id', 'email', 'username', 'is_active') diff --git a/app/Services/Admin/HR/LeaveRequestService.php b/app/Services/Admin/HR/LeaveRequestService.php index 73c457f..479dde2 100644 --- a/app/Services/Admin/HR/LeaveRequestService.php +++ b/app/Services/Admin/HR/LeaveRequestService.php @@ -23,7 +23,7 @@ public function getAll(array $filters = []): Collection ->get(); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator { return LeaveRequest::query() ->select('id', 'employee_id', 'start_date', 'end_date', 'total_days', 'status', 'created_at') diff --git a/app/Services/Admin/Master/CategoryService.php b/app/Services/Admin/Master/CategoryService.php index b6af156..b030c0d 100644 --- a/app/Services/Admin/Master/CategoryService.php +++ b/app/Services/Admin/Master/CategoryService.php @@ -13,7 +13,7 @@ public function getAll(): Collection return Category::select('id', 'name')->latest()->get(); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator { return Category::query() ->select('id', 'name') diff --git a/app/Services/Admin/Master/CustomerService.php b/app/Services/Admin/Master/CustomerService.php index f66db3f..023b6b7 100644 --- a/app/Services/Admin/Master/CustomerService.php +++ b/app/Services/Admin/Master/CustomerService.php @@ -13,7 +13,7 @@ public function getAll(): Collection return Customer::select('id', 'name', 'phone_number', 'address')->latest()->get(); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator { return Customer::query() ->select('id', 'name', 'phone_number', 'address') diff --git a/app/Services/Admin/Master/Product/ProductService.php b/app/Services/Admin/Master/Product/ProductService.php index f6686f9..74968f8 100644 --- a/app/Services/Admin/Master/Product/ProductService.php +++ b/app/Services/Admin/Master/Product/ProductService.php @@ -43,7 +43,7 @@ public function getAll(array $filters = []): Collection return $products; } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc', array $filters = []): LengthAwarePaginator { $paginator = Product::query() ->select('id', 'name', 'slug', 'description', 'status') @@ -242,10 +242,12 @@ public function update(Product $product, array $data): Product $variant = $existingVariantsMap[$variantId]; $oldStockDataMap[$variantId] = $variant->only(['stock', 'reject_stock', 'retail_stock']); - if ($variant->name !== $variantData['name'] + if ( + $variant->name !== $variantData['name'] || $variant->stock != $variantData['stock'] || $variant->reject_stock != $variantData['reject_stock'] - || $variant->retail_stock != $variantData['retail_stock']) { + || $variant->retail_stock != $variantData['retail_stock'] + ) { $changedIds[] = $variantId; } } diff --git a/app/Services/Admin/Master/SupplierService.php b/app/Services/Admin/Master/SupplierService.php index 0dc2f3f..f25aa0e 100644 --- a/app/Services/Admin/Master/SupplierService.php +++ b/app/Services/Admin/Master/SupplierService.php @@ -13,7 +13,7 @@ public function getAll(): Collection return Supplier::select('id', 'name', 'phone_number', 'address')->latest()->get(); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator { return Supplier::query() ->select('id', 'name', 'phone_number', 'address') diff --git a/app/Services/Admin/Settings/RoleService.php b/app/Services/Admin/Settings/RoleService.php index f074430..b91b1bf 100644 --- a/app/Services/Admin/Settings/RoleService.php +++ b/app/Services/Admin/Settings/RoleService.php @@ -15,7 +15,7 @@ public function getAll(): Collection return Role::withCount('permissions')->get(); } - public function paginated(int $perPage = 15, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator + public function paginated(int $perPage = 25, string $search = '', string $sort = 'created_at', string $direction = 'desc'): LengthAwarePaginator { return Role::query() ->withCount('permissions')