i wanted to ask is it possible to update the book’s stock before deleting borrowDetail
the code provided below is where i’m trying using Observer but still doesn’t work
public function deleting(BorrowDetail $borrowDetail): void
{
$book = Book::where('id', $borrowDetail->book_id)->first();
$book->stock += $borrowDetail->qty;
$book->save();
}
this is where i registered the Observer
<?php
namespace AppProviders;
use AppModelsBorrowDetail;
use AppObserversBorrowDetailObserver;
use IlluminateSupportServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
BorrowDetail::observe(BorrowDetailObserver::class);
}
}
And I delete it on Laravel Filament’s Edit Page, there is a delete Button. It was on BorrowResource.