From 290104eea76e2c495b14ab000a8e23c23669c1db Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 7 May 2020 00:36:33 +0100 Subject: [PATCH] Added view forms --- app/Http/Controllers/FormController.php | 24 +++- .../administration/formbuilder.blade.php | 10 +- .../dashboard/administration/forms.blade.php | 109 ++++++++++++++++++ .../administration/positions.blade.php | 2 +- routes/web.php | 3 + 5 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 resources/views/dashboard/administration/forms.blade.php 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 @@ -
- -
- - diff --git a/resources/views/dashboard/administration/forms.blade.php b/resources/views/dashboard/administration/forms.blade.php new file mode 100644 index 0000000..814dc7e --- /dev/null +++ b/resources/views/dashboard/administration/forms.blade.php @@ -0,0 +1,109 @@ +@extends('adminlte::page') + +@section('title', 'Raspberry Network | Application Form Management Tool') + +@section('content_header') + +

Administration / Forms

+ +@stop + +@section('js') + + @if (session()->has('success')) + + + + @elseif(session()->has('error')) + + + + + @endif + +@stop + +@section('content') + +
+ +
+ +
+ +
+

Available Forms

+
+ +
+ + @if(!$forms->isEmpty()) + + + + + + + + + + + + + + + + + @foreach($forms as $form) + + + + + + + + + @endforeach + + + +
#Form TitleCreated OnActions
{{$form->id}}{{$form->formName}}{{$form->created_at}} +
+ + @method('DELETE') + @csrf + + +
+ +
+ + @else + +
+ + Nothing to see here! Please add some forms first. + +
+ + @endif + +
+ + + +
+ +
+ +
+ +@stop diff --git a/resources/views/dashboard/administration/positions.blade.php b/resources/views/dashboard/administration/positions.blade.php index 4f80e5d..87f0eb6 100644 --- a/resources/views/dashboard/administration/positions.blade.php +++ b/resources/views/dashboard/administration/positions.blade.php @@ -78,7 +78,7 @@ diff --git a/routes/web.php b/routes/web.php index 1299e9d..2c72708 100644 --- a/routes/web.php +++ b/routes/web.php @@ -73,6 +73,9 @@ Route::group(['middleware' => 'auth'], function(){ Route::post('forms/save', 'FormController@saveForm') ->name('saveForm'); + Route::delete('forms/destroy/{id}', 'FormController@destroy') + ->name('destroyForm'); + Route::get('forms', 'FormController@index') ->name('showForms');