Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarzin committed Nov 1, 2023
1 parent ee64335 commit 212028c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
21 changes: 7 additions & 14 deletions app/Http/Controllers/ControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ public function plan(int $id)
if ($control === null) {
return;
}

xxxxx
$years = [];
$cur_year = Carbon::now()->year;
for ($i = 0; $i <= 3; $i++) {
Expand Down Expand Up @@ -645,9 +645,7 @@ public function doPlan(Request $request)
$control = Control::find($request->id);

// Control not found
if ($control === null) {
abort(404);
}
abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');

// Control already made ?
if ($control->realisation_date !== null) {
Expand Down Expand Up @@ -683,11 +681,10 @@ public function make(Request $request)

$id = (int) request('id');

// Control not found
$control = Control::find($id);
if ($control === null) {
abort(404);
}

// Control not found
abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');

// Control already made ?
if ($control->realisation_date !== null) {
Expand Down Expand Up @@ -732,9 +729,7 @@ public function doMake()
$control = Control::find($id);

// Control not found
if ($control === null) {
abort(404);
}
abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');

// control already made ?
if ($control->realisation_date !== null) {
Expand Down Expand Up @@ -790,9 +785,7 @@ public function save(Request $request)
$control = Control::find($request->id);

// Control not found
if ($control === null) {
abort(404);
}
abort_if($control === null, Response::HTTP_NOT_FOUND, '404 Not Found');

$control->name = request('name');
$control->scope = request('scope');
Expand Down
1 change: 0 additions & 1 deletion resources/views/measures/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
</form>
&nbsp;
<form action="/alice/delete/{{ $measure->id }}" method="POST" onSubmit="if(!confirm('{{ trans('common.confirm') }}')){return false;}">
@csrf
<button class="button alert" type="submit">
<span class="mif-fire"></span>
&nbsp;
Expand Down

0 comments on commit 212028c

Please sign in to comment.