From e8f2ee8fef9ebe2c186406f7aeaef74cfc9018c5 Mon Sep 17 00:00:00 2001 From: didier Date: Wed, 25 Sep 2024 18:27:53 +0200 Subject: [PATCH 1/2] fix error message --- app/Http/Controllers/DomainController.php | 12 ++++++------ resources/views/domains/show.blade.php | 11 +++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php index 2634622..cec1550 100644 --- a/app/Http/Controllers/DomainController.php +++ b/app/Http/Controllers/DomainController.php @@ -149,13 +149,13 @@ public function destroy(Domain $domain) abort_if(Auth::User()->role !== 1, Response::HTTP_FORBIDDEN, '403 Forbidden'); // Has measures ? - abort_if( - DB::table('measures') + if (DB::table('measures') ->where('domain_id', $domain->id) - ->exists(), - Response::HTTP_FORBIDDEN, - '403 Forbidden' - ); + ->exists()) { + return back() + ->withErrors(['msg' => 'There are controls associated with this framework !']) + ->withInput(); + } $domain->delete(); diff --git a/resources/views/domains/show.blade.php b/resources/views/domains/show.blade.php index 15b2752..b2fb8f3 100644 --- a/resources/views/domains/show.blade.php +++ b/resources/views/domains/show.blade.php @@ -3,6 +3,17 @@ @section("content")
+ @if (count($errors)) +
+
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+
+ @endif
From edc03e7e88bbfbaaec5a898e5d99c5230489141a Mon Sep 17 00:00:00 2001 From: didier Date: Wed, 25 Sep 2024 18:28:22 +0200 Subject: [PATCH 2/2] code quality --- app/Http/Controllers/DomainController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DomainController.php b/app/Http/Controllers/DomainController.php index cec1550..6caa201 100644 --- a/app/Http/Controllers/DomainController.php +++ b/app/Http/Controllers/DomainController.php @@ -150,12 +150,12 @@ public function destroy(Domain $domain) // Has measures ? if (DB::table('measures') - ->where('domain_id', $domain->id) - ->exists()) { + ->where('domain_id', $domain->id) + ->exists()) { return back() ->withErrors(['msg' => 'There are controls associated with this framework !']) ->withInput(); - } + } $domain->delete();