feat(expense): menyesuaikan logika penghapusan data agar kas dari barbershopnya kembali jika pengeluran tersebut menggunakan kas ,memperbaiki route model binding dan viewsnya
This commit is contained in:
parent
59fb6b94be
commit
86efb6cd04
@ -93,7 +93,15 @@ public function update(ExpenseRequest $request, Expense $expense): RedirectRespo
|
||||
|
||||
public function delete(Expense $expense): RedirectResponse
|
||||
{
|
||||
$expense->delete();
|
||||
$barbershop = Barbershop::findOrFail($expense->barbershop_id);
|
||||
|
||||
DB::transaction(function () use ($expense, $barbershop) {
|
||||
if ($expense->use_cash === '1') {
|
||||
$barbershop->increment('cash', $expense->amount);
|
||||
}
|
||||
|
||||
$expense->delete();
|
||||
});
|
||||
|
||||
notify()->success('Data berhasil dihapus', 'Berhasil');
|
||||
|
||||
|
||||
@ -27,12 +27,12 @@ public function register(): void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Route::bind('barbershop', fn(string $barbershop) => Barbershop::findOrFail(decryptId($barbershop)));
|
||||
Route::bind('user', fn(string $user) => User::findOrFail(decryptId($user)));
|
||||
Route::bind('customer', fn(string $customer) => Customer::findOrFail(decryptId($customer)));
|
||||
Route::bind('service', fn(string $service) => Service::findOrFail(decryptId($service)));
|
||||
Route::bind('expense', fn(string $expense) => Expense::findOrFail(decryptId($expense)));
|
||||
Route::bind('payroll', fn(string $payroll) => Payroll::findOrFail(decryptId($payroll)));
|
||||
Route::bind('cash', fn(string $cash) => Cash::findOrFail(decryptId($cash)));
|
||||
Route::bind('barbershop', fn (string $barbershop) => Barbershop::findOrFail(decryptId($barbershop)));
|
||||
Route::bind('user', fn (string $user) => User::findOrFail(decryptId($user)));
|
||||
Route::bind('customer', fn (string $customer) => Customer::findOrFail(decryptId($customer)));
|
||||
Route::bind('service', fn (string $service) => Service::findOrFail(decryptId($service)));
|
||||
Route::bind('expense', fn (string $expense) => Expense::findOrFail(decryptId($expense)));
|
||||
Route::bind('payroll', fn (string $payroll) => Payroll::findOrFail(decryptId($payroll)));
|
||||
Route::bind('cash', fn (string $cash) => Cash::findOrFail(decryptId($cash)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,6 @@ class="form-control rupiah-format @error('amount') is-invalid @enderror" id="amo
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-lg-12 position-relative">
|
||||
<<<<<<< HEAD
|
||||
<label class="form-label" for="use_cash">Gunakan Kas</label>
|
||||
<div class="form-check radio ps-0">
|
||||
<ul class="radio-wrapper">
|
||||
@ -149,8 +148,6 @@ class="form-control rupiah-format @error('amount') is-invalid @enderror" id="amo
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-lg-12 position-relative">
|
||||
=======
|
||||
>>>>>>> 21e2ec04bd9458fd280d8f46f52746684c355e1c
|
||||
<label class="form-label" for="proof">Bukti
|
||||
<span class="form-span"><i>(.jpeg,.png,.jpg,.gif,.svg)</i></span>
|
||||
</label>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user