diff --git a/app/Http/Controllers/SurveyController.php b/app/Http/Controllers/SurveyController.php index c49e9864..38ec9577 100644 --- a/app/Http/Controllers/SurveyController.php +++ b/app/Http/Controllers/SurveyController.php @@ -11,7 +11,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; -use App\Models\SurveyCoronaState; +use App\Models\SurveyVaccinationState; use App\Helpers\AccessHelper as Access; use \Carbon\Carbon; use Response; @@ -22,44 +22,62 @@ class SurveyController extends ExtendedController { public function __construct() { - $this->middleware(['auth' => 'surveyPermissions'])->except('surveyCoronaState', 'surveyCoronaStateSave'); + $this->middleware(['auth' => 'surveyPermissions'])->except('surveyVaccinationState', 'surveyVaccinationStateSave'); parent::__construct(); } - public function surveyCoronaState(Request $request) + public function surveyVaccinationState(Request $request) { - $formdata = new SurveyCoronaState(); - $view = view("inc.survey.coronaState"); + $formdata = new SurveyVaccinationState(); + $view = view("inc.survey.vaccinationState"); $view->with('url', $this->route); $view->with('formdata', $formdata); + $view->with('expired', false); return $view; } - public function surveyCoronaStateSave(Request $request) + public function surveyVaccinationStateSave(Request $request) { - $request->request->add(['city' => $request->city[0]]); - $formdata = $request->validate([ + $request->request->add(['state' => $request->state[0]]); + $request->request->add(['age' => $request->age[0]]); + + $validationData = [ 'department' => 'required', 'state' => 'required|min:3', - 'expiration_date' => 'date_format:d.m.Y', - ], - [ - 'department.required' => 'Pflichtfeld', - 'state.required' => 'Pflichtfeld', - 'state.min' => 'Mindestens :min Zeichen', - 'birthday.date_format' => 'Das Datum muss im Format tt.mm.jjjj (tag.monat.jahr) eingegeben werden', - ]); + 'age' => 'required', + ]; + if(strtolower($request->state) == 'geimpft' or strtolower($request->state) == 'genesen') + { + $validationData['expiration_date'] = 'date_format:d.m.Y|after:today'; + } - $model = new SurveyCoronaState(); + $formdata = $request->validate( + $validationData, + [ + 'department.required' => 'Pflichtfeld', + 'age.required' => 'Pflichtfeld', + 'state.required' => 'Pflichtfeld', + 'state.min' => 'Mindestens :min Zeichen', + 'expiration_date.date_format' => 'Das Datum muss im Format tt.mm.jjjj (tag.monat.jahr) eingegeben werden', + 'expiration_date.after' => 'Das Datum muss in der Zukunft liegen', + ]); + + $expiration_date = Carbon::createFromDate(1900, 1, 1); + if(strtolower($request->state) == 'geimpft' or strtolower($request->state) == 'genesen') + { + $expiration_date = Carbon::createFromFormat('d.m.Y', $request->expiration_date); + } + + $model = new SurveyVaccinationState(); $model->fill($request->all()); - $model->expiration_date = Carbon::createFromFormat('d.m.Y', $request->birthday); + $model->expiration_date = $expiration_date; $model->department = $request->department[0]; $model->survey_id = 1; $model->save(); - $view = view("inc.contact.surveyCoronaStateSuccess"); + $view = view("inc.survey.vaccinationStateSuccess"); return $view; diff --git a/app/Models/SurveyCoronaState.php b/app/Models/SurveyVaccinationState.php similarity index 81% rename from app/Models/SurveyCoronaState.php rename to app/Models/SurveyVaccinationState.php index 1f9a9d07..893f5f5b 100755 --- a/app/Models/SurveyCoronaState.php +++ b/app/Models/SurveyVaccinationState.php @@ -13,14 +13,15 @@ use Carbon\Carbon; use App\Helpers\PostHelper; use App\Http\Controllers\ServiceController; -class SurveyCoronaState extends ExtendedModel +class SurveyVaccinationState extends ExtendedModel { protected $fillable = [ 'survey_id', 'department', 'state', 'expiration_date', + 'age' ]; - protected $table = 'survey_corona_state'; + protected $table = 'survey_vaccination_state'; } diff --git a/database/migrations/2021_11_25_065800_create_survey_corona_state_table.php b/database/migrations/2021_11_25_065800_create_survey_vaccination_state_table.php similarity index 72% rename from database/migrations/2021_11_25_065800_create_survey_corona_state_table.php rename to database/migrations/2021_11_25_065800_create_survey_vaccination_state_table.php index 228b9484..25c0b8f4 100644 --- a/database/migrations/2021_11_25_065800_create_survey_corona_state_table.php +++ b/database/migrations/2021_11_25_065800_create_survey_vaccination_state_table.php @@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateSurveyCoronaStateTable extends Migration +class CreateSurveyVaccinationStateTable extends Migration { /** * Run the migrations. @@ -13,12 +13,13 @@ class CreateSurveyCoronaStateTable extends Migration */ public function up() { - Schema::create('survey_corona_state', function (Blueprint $table) { + Schema::create('survey_vaccination_state', function (Blueprint $table) { $table->increments('id'); $table->integer('survey_id'); $table->string('department', 20); $table->string('state', 50); $table->date('expiration_date'); + $table->string('age'); $table->timestamps(); $table->softDeletes(); }); @@ -31,6 +32,6 @@ class CreateSurveyCoronaStateTable extends Migration */ public function down() { - Schema::dropIfExists('subscribe_vaccinate'); + Schema::dropIfExists('survey_vaccination_state'); } } diff --git a/resources/views/inc/survey/vaccinationState.blade.php b/resources/views/inc/survey/vaccinationState.blade.php new file mode 100644 index 00000000..2110bd53 --- /dev/null +++ b/resources/views/inc/survey/vaccinationState.blade.php @@ -0,0 +1,126 @@ +@extends('layouts.app') + +@section('social_media') + + +@endsection + +@section('content') +
+
+

+ Anonyme Abfrage des Impfstatus für Feuerwehrangehörige der Freiwilligen Feuerwehr Eppingen - Gesamtwehr +

+
+
+
+
+
+
+ + @if($expired) +
+
+ Es tut uns Leid, aber der Zeitraum für die Statusabfrage ist abgelaufen. +
+
+ @else +
+
+
+ Um die Einsatzbereitschaft besser abschätzen zu können bitten wir alle aktiven Angehörigen der Freiwilligen Feuerwehr Eppingen - Gesamtwehr an dieser Umfrage teilzunehmen. + Die Umfrage findet absolut anonym statt. + Es werden lediglich die Daten aus dem untenstehenden Formular gespeichert. +
+
+
+
+
+
+ + @include('inc.forms.inputSelect', [ + 'name' => 'department', + 'label' => 'Abteilung *', + 'placeholder' => 'Abteilung', + 'selected' => old('department.0'), + 'modelValue' => 'department', + 'modelLabel' => 'department', + 'models' => [ + (object)['department' => ''], + (object)['department' => 'Adelshofen'], + (object)['department' => 'Elsenz'], + (object)['department' => 'Eppingen'], + (object)['department' => 'Kleingartach'], + (object)['department' => 'Mühlbach'], + (object)['department' => 'Richen'], + (object)['department' => 'Rohrbach'] + ] + ]) + @include('inc.forms.inputSelect', [ + 'name' => 'age', + 'label' => 'Alter *', + 'placeholder' => '', + 'selected' => old('age'), + 'modelValue' => 'age', + 'modelLabel' => 'age', + 'models' => [ + (object)['age' => ''], + (object)['age' => '18-25'], + (object)['age' => '26-35'], + (object)['age' => '36-45'], + (object)['age' => '46-55'], + (object)['age' => '56-65'], + ] + ]) + @include('inc.forms.inputSelect', [ + 'name' => 'state', + 'label' => 'Impf-/Genesenenstatus *', + 'placeholder' => '', + 'selected' => old('state'), + 'modelValue' => 'state', + 'modelLabel' => 'state', + 'models' => [ + (object)['state' => ''], + (object)['state' => 'Geimpft'], + (object)['state' => 'Genesen'], + (object)['state' => 'Ich möchte mich vorerst nicht impfen lassen'], + ] + ]) + @include('inc.forms.inputText', [ + 'name' => 'expiration_date', + 'label' => 'Impf-/Genesenenstatus gültig bis', + 'placeholder' => 'tt.mm.jjjj', + 'value' => $formdata->expiration_date + ]) + +
+ * Pflichtfeld +
+
+ +
+
+
+
+ @endif +
+ +
+
+@endsection \ No newline at end of file diff --git a/resources/views/inc/survey/vaccinationStateSuccess.blade.php b/resources/views/inc/survey/vaccinationStateSuccess.blade.php new file mode 100644 index 00000000..30099458 --- /dev/null +++ b/resources/views/inc/survey/vaccinationStateSuccess.blade.php @@ -0,0 +1,31 @@ +@extends('layouts.app') + +@section('social_media') + + +@endsection + +@section('content') +
+
+

+ Teilnahmebestätigung +

+
+
+
+
+
+
+
+
+ Vielen Dank für die Teilnahme.
+
+ Eure Feuerwehr Eppingen +
+
+
+
+ +
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index e9e9749f..096ce9ec 100755 --- a/routes/web.php +++ b/routes/web.php @@ -95,6 +95,17 @@ Route::post("anmeldung/abschliessen", [ 'middleware' => 'auth', function (){} ]); +Route::get("umfrage/impfstatus", [ + "uses" => "SurveyController@surveyVaccinationState", +], [ + 'middleware' => 'auth', function (){} +]); + +Route::post("umfrage/impfstatus/abschliessen", [ + "uses" => "SurveyController@surveyVaccinationStateSave", +], [ + 'middleware' => 'auth', function (){} +]); /****************************************/ /* Standard Routen für den User-Bereich */