feat: update services and controllers to include user information in transaction notifications for improved clarity
This commit is contained in:
parent
08d3982aa5
commit
0489badf03
@ -47,14 +47,14 @@ public function update(CashTransactionRequest $request, CashTransaction $cashTra
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$this->cashService->updateDeposit($cashTransaction, $request->validated());
|
||||
$this->cashService->updateDeposit($cashTransaction, $request->validated(), $request->user());
|
||||
|
||||
$this->flashUpdated('Setor kas');
|
||||
|
||||
return redirect()->route('admin.finance.cash.index');
|
||||
}
|
||||
|
||||
public function destroy(CashTransaction $cashTransaction): RedirectResponse
|
||||
public function destroy(Request $request, CashTransaction $cashTransaction): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$cashTransaction->ensureEditable();
|
||||
@ -62,7 +62,7 @@ public function destroy(CashTransaction $cashTransaction): RedirectResponse
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$this->cashService->deleteTransaction($cashTransaction);
|
||||
$this->cashService->deleteTransaction($cashTransaction, $request->user());
|
||||
|
||||
$this->flashDeleted('Setor kas');
|
||||
|
||||
|
||||
@ -42,16 +42,16 @@ public function store(ExpenseRequest $request): RedirectResponse
|
||||
|
||||
public function update(ExpenseRequest $request, Expense $expense): RedirectResponse
|
||||
{
|
||||
$this->expenseService->update($expense, $request->validated());
|
||||
$this->expenseService->update($expense, $request->validated(), $request->user());
|
||||
|
||||
$this->flashUpdated('Pengeluaran');
|
||||
|
||||
return redirect()->route('admin.finance.expenses.index');
|
||||
}
|
||||
|
||||
public function destroy(Expense $expense): RedirectResponse
|
||||
public function destroy(Request $request, Expense $expense): RedirectResponse
|
||||
{
|
||||
$this->expenseService->delete($expense);
|
||||
$this->expenseService->delete($expense, $request->user());
|
||||
|
||||
$this->flashDeleted('Pengeluaran');
|
||||
|
||||
|
||||
@ -51,9 +51,9 @@ public function checkOut(CheckOutRequest $request): RedirectResponse
|
||||
return redirect()->route('admin.hr.attendances.index');
|
||||
}
|
||||
|
||||
public function destroy(Attendance $attendance): RedirectResponse
|
||||
public function destroy(Request $request, Attendance $attendance): RedirectResponse
|
||||
{
|
||||
$this->attendanceService->delete($attendance);
|
||||
$this->attendanceService->delete($attendance, $request->user());
|
||||
|
||||
$this->flashDeleted('Presensi');
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ public function update(SubmitLeaveRequest $request, LeaveRequest $leaveRequest):
|
||||
return redirect()->route('admin.hr.leave_requests.index');
|
||||
}
|
||||
|
||||
public function destroy(LeaveRequest $leaveRequest): RedirectResponse
|
||||
public function destroy(Request $request, LeaveRequest $leaveRequest): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$leaveRequest->ensureEditable();
|
||||
@ -67,7 +67,7 @@ public function destroy(LeaveRequest $leaveRequest): RedirectResponse
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$this->leaveRequestService->delete($leaveRequest);
|
||||
$this->leaveRequestService->delete($leaveRequest, $request->user());
|
||||
|
||||
$this->flashDeleted('Pengajuan cuti');
|
||||
|
||||
|
||||
@ -81,16 +81,16 @@ public function edit(Cutting $cutting): Response|RedirectResponse
|
||||
|
||||
public function update(CuttingRequest $request, Cutting $cutting): RedirectResponse
|
||||
{
|
||||
$this->cuttingService->update($cutting, $request->validated());
|
||||
$this->cuttingService->update($cutting, $request->validated(), $request->user());
|
||||
|
||||
$this->flashUpdated('Proses cutting');
|
||||
|
||||
return redirect()->route('admin.manage.cuttings.index');
|
||||
}
|
||||
|
||||
public function destroy(Cutting $cutting): RedirectResponse
|
||||
public function destroy(Request $request, Cutting $cutting): RedirectResponse
|
||||
{
|
||||
$this->cuttingService->delete($cutting);
|
||||
$this->cuttingService->delete($cutting, $request->user());
|
||||
|
||||
$this->flashDeleted('Proses cutting');
|
||||
|
||||
|
||||
@ -97,16 +97,16 @@ public function edit(Order $order): Response|RedirectResponse
|
||||
|
||||
public function update(OrderRequest $request, Order $order): RedirectResponse
|
||||
{
|
||||
$this->orderService->update($order, $request->validated());
|
||||
$this->orderService->update($order, $request->validated(), $request->user());
|
||||
|
||||
$this->flashUpdated('Pesanan');
|
||||
|
||||
return redirect()->route('admin.manage.orders.index');
|
||||
}
|
||||
|
||||
public function destroy(Order $order): RedirectResponse
|
||||
public function destroy(Request $request, Order $order): RedirectResponse
|
||||
{
|
||||
$this->orderService->delete($order);
|
||||
$this->orderService->delete($order, $request->user());
|
||||
|
||||
$this->flashDeleted('Pesanan');
|
||||
|
||||
@ -117,7 +117,7 @@ public function transitionStatus(OrderStatusTransitionRequest $request, Order $o
|
||||
{
|
||||
$status = OrderStatus::from($request->validated('status'));
|
||||
|
||||
$this->orderService->transitionStatus($order, $status);
|
||||
$this->orderService->transitionStatus($order, $status, $request->user());
|
||||
|
||||
$this->flashSuccess($status->transitionStatusMessage());
|
||||
|
||||
|
||||
@ -224,7 +224,7 @@ function () use ($reference, $amount, $description, $user, $cashAccount): CashTr
|
||||
);
|
||||
}
|
||||
|
||||
public function updateDeposit(CashTransaction $transaction, array $validated): void
|
||||
public function updateDeposit(CashTransaction $transaction, array $validated, User $user): void
|
||||
{
|
||||
$this->runInTransaction(
|
||||
function () use ($transaction, $validated): void {
|
||||
@ -252,13 +252,13 @@ function () use ($transaction, $validated): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'✏️ Transaksi Kas Diperbarui',
|
||||
"Transaksi kas dengan keterangan {$transaction->description} diperbarui menjadi senilai {$transaction->amount_formatted}.",
|
||||
"Transaksi kas dengan keterangan {$transaction->description} diperbarui menjadi senilai {$transaction->amount_formatted} oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'admin-toko'],
|
||||
route('admin.finance.cash.index'),
|
||||
);
|
||||
}
|
||||
|
||||
public function deleteTransaction(CashTransaction $transaction): void
|
||||
public function deleteTransaction(CashTransaction $transaction, User $user): void
|
||||
{
|
||||
$amountFormatted = $transaction->amount_formatted;
|
||||
$description = $transaction->description;
|
||||
@ -285,7 +285,7 @@ function () use ($transaction): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'🗑️ Transaksi Kas Dihapus',
|
||||
"Transaksi kas senilai {$amountFormatted} dengan keterangan {$description} telah dihapus.",
|
||||
"Transaksi kas senilai {$amountFormatted} dengan keterangan {$description} telah dihapus oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'admin-toko'],
|
||||
route('admin.finance.cash.index'),
|
||||
);
|
||||
|
||||
@ -125,7 +125,7 @@ function () use ($employeeAdvance): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'🗑️ Kasbon Dihapus',
|
||||
"Kasbon sebesar {$amountFormatted} dengan keterangan {$description} telah dihapus.",
|
||||
"Kasbon sebesar {$amountFormatted} dengan keterangan {$description} telah dihapus oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.finance.employee_advances.index'),
|
||||
);
|
||||
|
||||
@ -89,7 +89,7 @@ function () use ($validated, $user): Expense {
|
||||
);
|
||||
}
|
||||
|
||||
public function update(Expense $expense, array $validated): void
|
||||
public function update(Expense $expense, array $validated, User $user): void
|
||||
{
|
||||
$this->runInTransaction(
|
||||
function () use ($expense, $validated): void {
|
||||
@ -116,13 +116,13 @@ function () use ($expense, $validated): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'✏️ Pengeluaran Diperbarui',
|
||||
"Pengeluaran dengan keterangan {$expense->description} diperbarui menjadi sebesar {$expense->amount_formatted}.",
|
||||
"Pengeluaran dengan keterangan {$expense->description} diperbarui menjadi sebesar {$expense->amount_formatted} oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.finance.expenses.index'),
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(Expense $expense): void
|
||||
public function delete(Expense $expense, User $user): void
|
||||
{
|
||||
$amountFormatted = $expense->amount_formatted;
|
||||
$description = $expense->description;
|
||||
@ -141,7 +141,7 @@ function () use ($expense): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'🗑️ Pengeluaran Dihapus',
|
||||
"Pengeluaran sebesar {$amountFormatted} dengan keterangan {$description} telah dihapus.",
|
||||
"Pengeluaran sebesar {$amountFormatted} dengan keterangan {$description} telah dihapus oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.finance.expenses.index'),
|
||||
);
|
||||
|
||||
@ -164,7 +164,7 @@ function () use ($employee, $validated): int {
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(Attendance $attendance): void
|
||||
public function delete(Attendance $attendance, User $user): void
|
||||
{
|
||||
$attendance->loadMissing('employee.user.profile');
|
||||
$employeeName = $attendance->employee?->user?->profile?->full_name;
|
||||
@ -181,7 +181,7 @@ function () use ($attendance): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'🗑️ Presensi Dihapus',
|
||||
"Data presensi {$employeeName} tanggal {$date?->toDateString()} telah dihapus.",
|
||||
"Data presensi {$employeeName} tanggal {$date?->toDateString()} telah dihapus oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.hr.attendances.index'),
|
||||
);
|
||||
|
||||
@ -102,7 +102,7 @@ public function update(LeaveRequest $leaveRequest, array $validated, User $user)
|
||||
);
|
||||
}
|
||||
|
||||
public function delete(LeaveRequest $leaveRequest): void
|
||||
public function delete(LeaveRequest $leaveRequest, User $user): void
|
||||
{
|
||||
$totalDays = $leaveRequest->total_days;
|
||||
$employeeName = $leaveRequest->employee?->user?->profile?->full_name;
|
||||
@ -116,7 +116,7 @@ function () use ($leaveRequest): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'🗑️ Pengajuan Cuti Dihapus',
|
||||
"Pengajuan cuti {$totalDays} hari oleh {$employeeName} telah dihapus.",
|
||||
"Pengajuan cuti {$totalDays} hari oleh {$employeeName} telah dihapus oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.hr.leave_requests.index'),
|
||||
);
|
||||
|
||||
@ -562,7 +562,7 @@ function () use ($validated, $user): Cutting {
|
||||
return $cutting;
|
||||
}
|
||||
|
||||
public function update(Cutting $cutting, array $validated): void
|
||||
public function update(Cutting $cutting, array $validated, User $user): void
|
||||
{
|
||||
if (! $cutting->status->isEditable()) {
|
||||
throw ValidationException::withMessages([
|
||||
@ -650,7 +650,7 @@ function () use ($cutting, $validated): void {
|
||||
$description = $cutting->description ?? '-';
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'✏️ Proses Cutting Diperbarui',
|
||||
"Proses cutting dengan deskripsi '{$description}' telah diperbarui.",
|
||||
"Proses cutting dengan deskripsi '{$description}' telah diperbarui oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.cuttings.index'),
|
||||
);
|
||||
@ -658,7 +658,7 @@ function () use ($cutting, $validated): void {
|
||||
$this->cacheForgetByPattern('manage:cuttings:*');
|
||||
}
|
||||
|
||||
public function delete(Cutting $cutting): void
|
||||
public function delete(Cutting $cutting, User $user): void
|
||||
{
|
||||
if (! in_array($cutting->status, [CuttingStatus::IN_PROGRESS, CuttingStatus::REJECTED], true)) {
|
||||
throw ValidationException::withMessages([
|
||||
@ -688,7 +688,7 @@ function () use ($cutting): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'🗑️ Proses Cutting Dihapus',
|
||||
"Proses cutting dengan deskripsi {$description} telah dihapus.",
|
||||
"Proses cutting dengan deskripsi {$description} telah dihapus oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.cuttings.index'),
|
||||
);
|
||||
@ -759,11 +759,11 @@ function () use ($cutting, $status, $verificationNote, $results, $resultPrices,
|
||||
|
||||
$description = $cutting->description ?? '-';
|
||||
$message = match ($status) {
|
||||
CuttingStatus::COMPLETED => "Proses cutting dengan deskripsi '{$description}' telah selesai dan menunggu verifikasi.",
|
||||
CuttingStatus::VERIFIED => "Proses cutting dengan deskripsi '{$description}' telah diverifikasi.",
|
||||
CuttingStatus::REJECTED => "Proses cutting dengan deskripsi '{$description}' ditolak".($reason ? " dengan alasan: '{$reason}'" : '').'.',
|
||||
CuttingStatus::IN_PROGRESS => "Proses cutting dengan deskripsi '{$description}' dikembalikan ke proses.",
|
||||
default => "Status proses cutting dengan deskripsi '{$description}' telah diperbarui ke: {$status->label()}.",
|
||||
CuttingStatus::COMPLETED => "Proses cutting dengan deskripsi '{$description}' telah selesai oleh {$user->profile?->full_name} dan menunggu verifikasi.",
|
||||
CuttingStatus::VERIFIED => "Proses cutting dengan deskripsi '{$description}' telah diverifikasi oleh {$user->profile?->full_name}.",
|
||||
CuttingStatus::REJECTED => "Proses cutting dengan deskripsi '{$description}' ditolak oleh {$user->profile?->full_name}".($reason ? " dengan alasan: '{$reason}'" : '').'.',
|
||||
CuttingStatus::IN_PROGRESS => "Proses cutting dengan deskripsi '{$description}' dikembalikan ke proses oleh {$user->profile?->full_name}.",
|
||||
default => "Status proses cutting dengan deskripsi '{$description}' telah diperbarui ke: {$status->label()} oleh {$user->profile?->full_name}.",
|
||||
};
|
||||
|
||||
$title = match ($status) {
|
||||
|
||||
@ -508,7 +508,7 @@ function () use ($validated, $user): Order {
|
||||
return $order;
|
||||
}
|
||||
|
||||
public function update(Order $order, array $validated): void
|
||||
public function update(Order $order, array $validated, User $user): void
|
||||
{
|
||||
$order->ensureEditable();
|
||||
|
||||
@ -589,7 +589,7 @@ function () use ($order, $validated): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'✏️ Pesanan Diperbarui',
|
||||
"Pesanan {$order->order_number} senilai {$order->total_amount_formatted} telah diperbarui.",
|
||||
"Pesanan {$order->order_number} senilai {$order->total_amount_formatted} telah diperbarui oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.orders.index'),
|
||||
);
|
||||
@ -597,7 +597,7 @@ function () use ($order, $validated): void {
|
||||
$this->cacheForgetByPattern('manage:orders:*');
|
||||
}
|
||||
|
||||
public function delete(Order $order): void
|
||||
public function delete(Order $order, User $user): void
|
||||
{
|
||||
$orderNumber = $order->order_number;
|
||||
$totalAmount = $order->total_amount;
|
||||
@ -624,7 +624,7 @@ function () use ($order): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'🗑️ Pesanan Dihapus',
|
||||
"Pesanan {$orderNumber} senilai {$order->total_amount_formatted} telah dihapus.",
|
||||
"Pesanan {$orderNumber} senilai {$order->total_amount_formatted} telah dihapus oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.orders.index'),
|
||||
);
|
||||
@ -632,7 +632,7 @@ function () use ($order): void {
|
||||
$this->cacheForgetByPattern('manage:orders:*');
|
||||
}
|
||||
|
||||
public function transitionStatus(Order $order, OrderStatus $status): void
|
||||
public function transitionStatus(Order $order, OrderStatus $status, User $user): void
|
||||
{
|
||||
if (! $order->status->canTransitionTo($status)) {
|
||||
throw ValidationException::withMessages([
|
||||
@ -663,7 +663,7 @@ function () use ($order, $status): void {
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'📦 Status Pesanan Diubah',
|
||||
"Pesanan {$order->order_number} diubah statusnya menjadi {$status->label()}.",
|
||||
"Pesanan {$order->order_number} diubah statusnya menjadi {$status->label()} oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.orders.index'),
|
||||
);
|
||||
|
||||
@ -273,7 +273,7 @@ public function rejectRequest(
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'❌ Pengajuan Ditolak',
|
||||
"Pengajuan {$request->action->label()} {$subjectLabel} '{$title}' ditolak dengan alasan: '{$reason}'.",
|
||||
"Pengajuan {$request->action->label()} {$subjectLabel} '{$title}' ditolak oleh {$user->profile?->full_name} dengan alasan: '{$reason}'.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.dashboard'),
|
||||
);
|
||||
|
||||
@ -35,7 +35,7 @@ public function transfer(int $variantId, int $quantity, User $user, ?string $not
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'📦 Perubahan Stok Ecer',
|
||||
"Perubahan {$quantity} pcs stok ecer untuk varian '{$variant->name}' telah diterapkan.",
|
||||
"Perubahan {$quantity} pcs stok ecer untuk varian '{$variant->name}' telah diterapkan oleh {$user->profile?->full_name}.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.master.products.index', ['search_id' => $variant->product_id]),
|
||||
);
|
||||
|
||||
@ -142,14 +142,14 @@ public function submitVerification(
|
||||
if ($isOwner) {
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'📦 Stok Cutting Diverifikasi',
|
||||
"Cutting dengan deskripsi '{$description}' telah disetujui owner dan stok produk telah ditambahkan ke toko.",
|
||||
"Cutting dengan deskripsi '{$description}' telah disetujui oleh {$user->profile?->full_name} dan stok produk telah ditambahkan ke toko.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.stocks.index'),
|
||||
);
|
||||
} else {
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'📦 Verifikasi Stok Menunggu Persetujuan',
|
||||
"Cutting dengan deskripsi '{$description}' telah diajukan verifikasi dan menunggu persetujuan owner.",
|
||||
"Cutting dengan deskripsi '{$description}' telah diajukan verifikasi oleh {$user->profile?->full_name} dan menunggu persetujuan owner.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.stocks.index'),
|
||||
);
|
||||
@ -205,7 +205,7 @@ public function approveVerification(
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'📦 Stok Cutting Diverifikasi',
|
||||
"Cutting dengan deskripsi '{$description}' telah disetujui owner dan stok produk telah ditambahkan ke toko.",
|
||||
"Cutting dengan deskripsi '{$description}' telah disetujui oleh {$user->profile?->full_name} dan stok produk telah ditambahkan ke toko.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.stocks.index'),
|
||||
);
|
||||
@ -250,7 +250,7 @@ public function rejectVerification(
|
||||
$description = $cutting->description ?? '-';
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'📦 Verifikasi Cutting Ditolak Owner',
|
||||
"Cutting dengan deskripsi '{$description}' ditolak oleh owner dengan alasan: '{$reason}'.",
|
||||
"Cutting dengan deskripsi '{$description}' ditolak oleh {$user->profile?->full_name} dengan alasan: '{$reason}'.",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.manage.stocks.index'),
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user