Validaciones y Zonas de produccion

This commit is contained in:
2021-07-12 11:05:50 -04:00
parent 4f1dfd1221
commit d64dacee8d
9 changed files with 186 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ use App\Models\Sector;
use App\Services\PaginatorService;
use App\Services\UuidService;
use App\Exceptions\GenericException;
use App\Exceptions\CantdeletehasChild;
use App\Exceptions\ModelNotFoundException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -118,6 +119,10 @@ class SectoresController extends Controller {
throw new ModelNotFoundException("sector", $id);
}
if($sector->canalesVenta()->count() > 0) {
throw new CantDeleteHasChildException("sector", "canal_venta");
}
$sector->delete();
return response()->json([], 204);