resolve constrained delete

This commit is contained in:
2024-12-02 10:44:25 +03:30
parent a706406261
commit 985fda5cce

View File

@@ -9,6 +9,7 @@ use App\Http\Requests\V3\AzmayeshType\UpdateRequest;
use App\Http\Traits\ApiResponse; use App\Http\Traits\ApiResponse;
use App\Models\AzmayeshField; use App\Models\AzmayeshField;
use App\Models\AzmayeshType; use App\Models\AzmayeshType;
use Illuminate\Database\QueryException;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@@ -109,8 +110,13 @@ class AzmayeshTypeController extends Controller
*/ */
public function destroy(AzmayeshType $azmayeshType): JsonResponse public function destroy(AzmayeshType $azmayeshType): JsonResponse
{ {
$azmayeshType->delete(); try {
$azmayeshType->delete();
return $this->successResponse(); return $this->successResponse();
}
catch (QueryException $exception) {
return $this->errorResponse('can not be deleted');
}
} }
} }