refactor: update constructors to use readonly properties for service dependencies
This commit is contained in:
parent
5961a60585
commit
8970c47a4a
@ -16,7 +16,7 @@
|
||||
class AdminSettingsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private AdminSettingsService $service
|
||||
private readonly AdminSettingsService $service
|
||||
) {}
|
||||
|
||||
public function index(): Response
|
||||
@ -70,7 +70,7 @@ public function updateHR(UpdateHRRequest $request): RedirectResponse
|
||||
{
|
||||
$this->service->updateHR($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan hr berhasil diperbarui.']);
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan HR berhasil diperbarui.']);
|
||||
|
||||
return to_route('admin.settings.index');
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class CashAccountController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private CashAccountService $service
|
||||
private readonly CashAccountService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class EmployeeAdvanceController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private EmployeeAdvanceService $service
|
||||
private readonly EmployeeAdvanceService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class ExpenseController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private ExpenseService $service
|
||||
private readonly ExpenseService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
class PayrollAdjustmentController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private PayrollAdjustmentService $service
|
||||
private readonly PayrollAdjustmentService $service
|
||||
) {}
|
||||
|
||||
public function store(PayrollAdjustmentRequest $request, Payroll $payroll): RedirectResponse
|
||||
@ -21,7 +21,7 @@ public function store(PayrollAdjustmentRequest $request, Payroll $payroll): Redi
|
||||
fn () => $this->service->create($payroll, $request->validated()),
|
||||
'Adjustment gaji berhasil ditambahkan.',
|
||||
'admin.finance.payroll-periods.show',
|
||||
['payroll_period' => $payroll->payroll_period_id]
|
||||
parameters : ['payroll_period' => $payroll->payroll_period_id]
|
||||
);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ public function destroy(PayrollAdjustment $payrollAdjustment): RedirectResponse
|
||||
fn () => $this->service->delete($payrollAdjustment),
|
||||
'Adjustment gaji berhasil dihapus.',
|
||||
'admin.finance.payroll-periods.show',
|
||||
['payroll_period' => $payrollAdjustment->payroll->payroll_period_id]
|
||||
parameters: ['payroll_period' => $payrollAdjustment->payroll->payroll_period_id]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
class PayrollController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private PayrollPeriodService $service
|
||||
private readonly PayrollPeriodService $service
|
||||
) {}
|
||||
|
||||
public function pay(Payroll $payroll): RedirectResponse
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class PayrollPeriodController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private PayrollPeriodService $service
|
||||
private readonly PayrollPeriodService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
class AttendanceController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private AttendanceService $service
|
||||
private readonly AttendanceService $service
|
||||
) {}
|
||||
|
||||
public function index(Request $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class EmployeeController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private EmployeeService $service
|
||||
private readonly EmployeeService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class LeaveRequestController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private LeaveRequestService $service
|
||||
private readonly LeaveRequestService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class CuttingController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private CuttingService $service,
|
||||
private readonly CuttingService $service,
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class PurchaseController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private PurchaseService $service,
|
||||
private readonly PurchaseService $service,
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class RestockController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private RestockService $service,
|
||||
private readonly RestockService $service,
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private TransactionService $service,
|
||||
private readonly TransactionService $service,
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private CategoryService $service
|
||||
private readonly CategoryService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private CustomerService $service
|
||||
private readonly CustomerService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
class ProductController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private ProductService $service,
|
||||
private CategoryService $categoryService,
|
||||
private readonly ProductService $service,
|
||||
private readonly CategoryService $categoryService,
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
class ProductVariantController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private ProductVariantService $variantService,
|
||||
private readonly ProductVariantService $variantService,
|
||||
) {}
|
||||
|
||||
public function edit(Product $product, ProductVariant $variant): Response
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
class StockMutationController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private StockMutationService $service = new StockMutationService,
|
||||
private readonly StockMutationService $service,
|
||||
) {}
|
||||
|
||||
public function index(StockMutationRequest $request, Product $product, ProductVariant $variant): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class RawMaterialController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private RawMaterialService $service,
|
||||
private readonly RawMaterialService $service,
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class RawMaterialVariantController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private RawMaterialVariantService $variantService,
|
||||
private readonly RawMaterialVariantService $variantService,
|
||||
) {}
|
||||
|
||||
public function edit(RawMaterial $rawMaterial, RawMaterialPrice $variant): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class SupplierController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private SupplierService $service
|
||||
private readonly SupplierService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
class RoleController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private RoleService $service
|
||||
private readonly RoleService $service
|
||||
) {}
|
||||
|
||||
public function index(PaginatedRequest $request): Response
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
class PresignedUrlController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private S3PresignedService $service
|
||||
private readonly S3PresignedService $service
|
||||
) {}
|
||||
|
||||
public function store(PresignedUrlRequest $request): JsonResponse
|
||||
|
||||
@ -28,4 +28,9 @@ protected function handleAction(callable $action, string $successMessage, string
|
||||
return to_route($errorRoute ?? $redirectRoute, $parameters);
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleToggle(callable $action, string $successMessage, string $redirectRoute): RedirectResponse
|
||||
{
|
||||
return $this->handleAction($action, $successMessage, $redirectRoute);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,9 +12,6 @@
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the user's profile settings page.
|
||||
*/
|
||||
public function edit(Request $request): Response
|
||||
{
|
||||
$user = $request->user();
|
||||
@ -38,38 +35,37 @@ public function edit(Request $request): Response
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user's profile information.
|
||||
*/
|
||||
public function update(ProfileUpdateRequest $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validated();
|
||||
$user = $request->user();
|
||||
return $this->handleAction(
|
||||
function () use ($request) {
|
||||
$validated = $request->validated();
|
||||
$user = $request->user();
|
||||
|
||||
$user->fill([
|
||||
'email' => $validated['email'],
|
||||
'username' => $validated['username'],
|
||||
]);
|
||||
$user->fill([
|
||||
'email' => $validated['email'],
|
||||
'username' => $validated['username'],
|
||||
]);
|
||||
|
||||
if ($user->isDirty('email')) {
|
||||
$user->email_verified_at = null;
|
||||
}
|
||||
if ($user->isDirty('email')) {
|
||||
$user->email_verified_at = null;
|
||||
}
|
||||
|
||||
$user->save();
|
||||
$user->save();
|
||||
|
||||
$user->userProfile()->updateOrCreate(
|
||||
[],
|
||||
[
|
||||
'full_name' => $validated['full_name'],
|
||||
'phone_number' => $validated['phone_number'] ?? null,
|
||||
'gender' => $validated['gender'] ?? null,
|
||||
'birth_date' => $validated['birth_date'] ?? null,
|
||||
'address' => $validated['address'] ?? null,
|
||||
],
|
||||
$user->userProfile()->updateOrCreate(
|
||||
[],
|
||||
[
|
||||
'full_name' => $validated['full_name'],
|
||||
'phone_number' => $validated['phone_number'] ?? null,
|
||||
'gender' => $validated['gender'] ?? null,
|
||||
'birth_date' => $validated['birth_date'] ?? null,
|
||||
'address' => $validated['address'] ?? null,
|
||||
],
|
||||
);
|
||||
},
|
||||
'Profil berhasil diperbarui.',
|
||||
'profile.edit',
|
||||
);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Profil berhasil diperbarui.']);
|
||||
|
||||
return to_route('profile.edit');
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,26 +11,16 @@
|
||||
|
||||
class SecurityController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the user's security settings page.
|
||||
*/
|
||||
public function edit(): Response
|
||||
{
|
||||
$props = [
|
||||
return Inertia::render('settings/security', [
|
||||
'passwordRules' => Password::defaults()->toPasswordRulesString(),
|
||||
];
|
||||
|
||||
return Inertia::render('settings/security', $props);
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user's password.
|
||||
*/
|
||||
public function update(PasswordUpdateRequest $request): RedirectResponse
|
||||
{
|
||||
$request->user()->update([
|
||||
'password' => $request->password,
|
||||
]);
|
||||
$request->user()->update(['password' => $request->password]);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Kata sandi berhasil diperbarui.']);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user