From 9e7c7c584ef5082c6a004f498d68c1b904d0bc6a Mon Sep 17 00:00:00 2001 From: ro Date: Fri, 9 Feb 2024 15:12:04 -0600 Subject: [PATCH] Added more filtering for appeal check Appeal checks needed an emptry string filter so all requested data is accounted for and not left emptyAdded more filtering for appeal check --- app/Http/Controllers/AppealController.php | 33 ++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/AppealController.php b/app/Http/Controllers/AppealController.php index 31536bc..148e24b 100644 --- a/app/Http/Controllers/AppealController.php +++ b/app/Http/Controllers/AppealController.php @@ -30,19 +30,28 @@ class AppealController extends Controller 'error' => 'Appeal already in process for Location', ]); } else { - //TODO: Add empty string filtering and check if location exists in DB - $new = Appeal::create([ - 'uuid' => Uuid::uuid4(), - 'location' => $request->location, - 'location_admin' => $request->location_admin, - 'sponsor' => $request->sponsor, - 'description' => $request->appeal_description, - 'approved' => false, - 'reviewed' => false, - ]); - Mail::to(env('TBS_ADMIN_EMAIL'))->send(new LocationAppeal($request->location, $request->sponsor)); + if ( + empty($request->location) + || empty($request->location_admin) + || empty($request->sponsor) + || empty($request->appeal_description) + ) { + return back()->withErrors([ + 'error' => 'All fields are required', + ]); + } else { + $new = Appeal::create([ + 'uuid' => Uuid::uuid4(), + 'location' => $request->location, + 'location_admin' => $request->location_admin, + 'sponsor' => $request->sponsor, + 'description' => $request->appeal_description, + 'approved' => false, + 'reviewed' => false, + ]); + Mail::to(env('TBS_ADMIN_EMAIL'))->send(new LocationAppeal($request->location, $request->sponsor)); + } } - //return redirect('/appeals'); return back()->with('message', "Appeal Filed"); };