From 3bc938b3729a5624154c01bc7b7e0862604a6ef5 Mon Sep 17 00:00:00 2001 From: didier Date: Thu, 16 Jan 2025 09:56:29 +0100 Subject: [PATCH] fix domain API --- app/Http/Controllers/API/DomaineAdController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/API/DomaineAdController.php b/app/Http/Controllers/API/DomaineAdController.php index 71f1ff16..743acf2e 100644 --- a/app/Http/Controllers/API/DomaineAdController.php +++ b/app/Http/Controllers/API/DomaineAdController.php @@ -27,8 +27,9 @@ public function store(StoreDomaineAdRequest $request) abort_if(Gate::denies('domaine_ad_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $domaineAd = DomaineAd::create($request->all()); - $domaineAd->domainesForestAds()->sync($request->input('domainesForestAds', [])); - $domaineAd->logicalServers()->sync($request->input('logicalServers', [])); + if (request['domainesForestAds']!=null) + $domaineAd->domainesForestAds()->sync($request->input('domainesForestAds', [])); + // $domaineAd->logicalServers()->sync($request->input('logicalServers', [])); return response()->json($domaineAd, 201); } @@ -45,8 +46,9 @@ public function update(UpdateDomaineAdRequest $request, DomaineAd $domaineAd) abort_if(Gate::denies('domaine_ad_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $domaineAd->update($request->all()); - $domaineAd->domainesForestAds()->sync($request->input('domainesForestAds', [])); - $domaineAd->logicalServers()->sync($request->input('logicalServers', [])); + if (request['domainesForestAds']!=null) + $domaineAd->domainesForestAds()->sync($request->input('domainesForestAds', [])); + // $domaineAd->logicalServers()->sync($request->input('logicalServers', [])); return response()->json(); }