fix delete controller
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user