From 997b07a0b72dfd3140af1a9696037854e58faff5 Mon Sep 17 00:00:00 2001 From: cp6 Date: Sat, 5 Nov 2022 12:48:07 +1100 Subject: [PATCH] Update YabsController return formatting & compare data check Update YabsController return formatting Update for an is null check on data calling --- app/Http/Controllers/YabsController.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/YabsController.php b/app/Http/Controllers/YabsController.php index 2aae773..4504208 100644 --- a/app/Http/Controllers/YabsController.php +++ b/app/Http/Controllers/YabsController.php @@ -12,8 +12,7 @@ class YabsController extends Controller { public function index() { - $yabs = Yabs::allYabs(); - return view('yabs.index', compact(['yabs'])); + return view('yabs.index', ['yabs' => Yabs::allYabs()]); } public function create() @@ -28,8 +27,7 @@ class YabsController extends Controller public function show(Yabs $yab) { - $yab = Yabs::yabs($yab->id); - return view('yabs.show', compact(['yab'])); + return view('yabs.show', ['yabs' => Yabs::yabs($yab->id)]); } public function destroy(Yabs $yab) @@ -66,13 +64,13 @@ class YabsController extends Controller { $yabs1_data = Yabs::yabs($yabs1); - if (count($yabs1_data) === 0) { + if (is_null($yabs1_data)) { abort(404); } $yabs2_data = Yabs::yabs($yabs2); - if (count($yabs2_data) === 0) { + if (is_null($yabs2_data)) { abort(404); }