fix delete controller

This commit is contained in:
2025-05-27 15:54:14 +03:30
parent 151d7ed566
commit 9ca86bd924

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\V3\Dashboard;
use App\Enums\AccidentStates;
use App\Exceptions\ProhibitedAction;
use App\Exports\V3\AccidentReceipt\DataTableReport;
use App\Facades\DataTable\DataTableFacade;
use App\Facades\File\FileFacade;
@@ -26,6 +27,7 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Facades\Excel;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Throwable;
class AccidentReceiptController extends Controller
{
@@ -200,10 +202,13 @@ class AccidentReceiptController extends Controller
return $this->successResponse();
}
/**
* @throws Throwable
*/
public function destroy(Accident $accident): JsonResponse
{
abort_if($accident->status === AccidentStates::BEDON_EGHDAM->value, 422);
throw_if($accident->status != AccidentStates::BEDON_EGHDAM->value, new ProhibitedAction('قابلیت حذف در این مرحله وجود ندارد'));
FileFacade::deleteDirectory('receipts_files/' . $accident->id);