Used laravel validation for appeal form
Switched valdiation from checking for empty strings to using Laravel's built in form validation. It's pretty.
This commit is contained in:
parent
9e7c7c584e
commit
fe67927c24
1 changed files with 17 additions and 21 deletions
|
@ -30,27 +30,23 @@ class AppealController extends Controller
|
||||||
'error' => 'Appeal already in process for Location',
|
'error' => 'Appeal already in process for Location',
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
if (
|
$clean = $request->validate([
|
||||||
empty($request->location)
|
'location' => ['required'],
|
||||||
|| empty($request->location_admin)
|
'local_admin' => ['required'],
|
||||||
|| empty($request->sponsor)
|
'local_sponsor' => ['required'],
|
||||||
|| empty($request->appeal_description)
|
'appeal_description' => ['required'],
|
||||||
) {
|
]);
|
||||||
return back()->withErrors([
|
|
||||||
'error' => 'All fields are required',
|
$new = Appeal::create([
|
||||||
]);
|
'uuid' => Uuid::uuid4(),
|
||||||
} else {
|
'location' => $request->location,
|
||||||
$new = Appeal::create([
|
'location_admin' => $request->location_admin,
|
||||||
'uuid' => Uuid::uuid4(),
|
'sponsor' => $request->sponsor,
|
||||||
'location' => $request->location,
|
'description' => $request->appeal_description,
|
||||||
'location_admin' => $request->location_admin,
|
'approved' => false,
|
||||||
'sponsor' => $request->sponsor,
|
'reviewed' => false,
|
||||||
'description' => $request->appeal_description,
|
]);
|
||||||
'approved' => false,
|
Mail::to(env('TBS_ADMIN_EMAIL'))->send(new LocationAppeal($request->location, $request->sponsor));
|
||||||
'reviewed' => false,
|
|
||||||
]);
|
|
||||||
Mail::to(env('TBS_ADMIN_EMAIL'))->send(new LocationAppeal($request->location, $request->sponsor));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//return redirect('/appeals');
|
//return redirect('/appeals');
|
||||||
return back()->with('message', "Appeal Filed");
|
return back()->with('message', "Appeal Filed");
|
||||||
|
|
Loading…
Reference in a new issue