diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php index eb4cce8..f2fb854 100644 --- a/app/Http/Controllers/FormController.php +++ b/app/Http/Controllers/FormController.php @@ -11,7 +11,8 @@ class FormController extends Controller public function index() { - + return view('dashboard.administration.forms') + ->with('forms', Form::all()); } public function showFormBuilder() @@ -60,11 +61,30 @@ class FormController extends Controller ); $request->session()->flash('success', 'Form created! You can now link this form to a vacancy.'); - return redirect()->back(); + return redirect()->to(route('showForms')); } $request->session()->flash('errors', $validation->errors()->getMessages()); return redirect()->back(); } + public function destroy(Request $request, $id) + { + + $form = Form::find($id); + + // TODO: Check if form is linked to vacancies before allowing deletion + if (!is_null($form)) + { + $form->delete(); + + $request->session()->flash('success', 'Form deleted successfully.'); + return redirect()->back(); + } + + $request->session()->flash('error', 'The form you\'re trying to delete does not exist.'); + return redirect()->back(); + + } + } diff --git a/resources/views/dashboard/administration/formbuilder.blade.php b/resources/views/dashboard/administration/formbuilder.blade.php index d8b5158..7995024 100644 --- a/resources/views/dashboard/administration/formbuilder.blade.php +++ b/resources/views/dashboard/administration/formbuilder.blade.php @@ -21,7 +21,7 @@ @foreach(session('error') as $error) @endforeach @@ -53,17 +53,13 @@ -
# | +Form Title | +Created On | +Actions | +
---|---|---|---|
{{$form->id}} | +{{$form->formName}} | +{{$form->created_at}} | ++ + + | +