From eb54ef5a24bc4af0749ad43ccffcbc1ae03aa4b6 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 1 Nov 2020 23:55:13 +0100 Subject: Special callsigns finished. --- app/Http/Controllers/SpecialCallsController.php | 41 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'app') diff --git a/app/Http/Controllers/SpecialCallsController.php b/app/Http/Controllers/SpecialCallsController.php index 2c63c22..dd05810 100644 --- a/app/Http/Controllers/SpecialCallsController.php +++ b/app/Http/Controllers/SpecialCallsController.php @@ -36,7 +36,7 @@ class SpecialCallsController extends Controller $newcall->description = $request->description; $newcall->saveOrFail(); - return Redirect::back()->with('status', 'Callsign added.'); + return Redirect::back()->with('status', "Special callsign added."); } public function edit(Request $request, int $id) @@ -47,21 +47,34 @@ class SpecialCallsController extends Controller public function editForm(Request $request, int $id) { - $rules = [ 'sign' => 'required' ]; - $messages = [ 'sign.required' => 'You need to provide a callsign!' ]; - $validator = Validator::make($request->all(), $rules, $messages); + //dd($request->input('submit')); + if ($request->input('submit') == 'Edit callsign') { + $rules = [ 'sign' => 'required' ]; + $messages = [ 'sign.required' => 'You need to provide a callsign!' ]; + $validator = Validator::make($request->all(), $rules, $messages); - if ($validator->fails()) { - return Redirect::back() - ->withErrors($validator) - ->withInput(); - } + if ($validator->fails()) { + return Redirect::back() + ->withErrors($validator) + ->withInput(); + } - $data = SpecialCall::findOrFail($id); - $data->sign = strtoupper($request->sign); - $data->description = $request->description; - $data->saveOrFail(); + $data = SpecialCall::findOrFail($id); + $data->sign = strtoupper($request->sign); + $data->description = $request->description; + $data->saveOrFail(); + + return Redirect::route('addSign')->with('statusE', "Special callsign edited."); + } else return Redirect::route('addSign'); + } - return Redirect::back()->with('statusE', 'Callsign edited.'); + public function delete(Request $request, int $id) + { + //SpecialCall::findOrFail($id)->delete(); + $sign = SpecialCall::findOrFail($id); + $call = $sign->sign; + $sign->delete(); + return Redirect::back()->with('statusE', "Special callsign $call deleted."); } + } -- cgit v1.2.3