From 8494c67377b499ea18c544662c9a7e3db6936106 Mon Sep 17 00:00:00 2001 From: Krzysztof Strzelecki Date: Sun, 6 Oct 2019 00:56:23 +0200 Subject: [PATCH] =?UTF-8?q?dodanie=20stopni=20stra=C5=BCackich=20i=20funkc?= =?UTF-8?q?ji=20w=20jednostce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/fireFightersController.php | 11 +++-- .../2019_10_05_185538_create_ranks_table.php | 40 +++++++++++++++++++ ...0_05_215707_create_unitFunctions_table.php | 39 ++++++++++++++++++ resources/views/fireFightersAdd.blade.php | 20 ++++++++++ 4 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2019_10_05_185538_create_ranks_table.php create mode 100644 database/migrations/2019_10_05_215707_create_unitFunctions_table.php diff --git a/app/Http/Controllers/fireFightersController.php b/app/Http/Controllers/fireFightersController.php index db0870f..806a1ac 100644 --- a/app/Http/Controllers/fireFightersController.php +++ b/app/Http/Controllers/fireFightersController.php @@ -28,7 +28,10 @@ class fireFightersController extends Controller if(auth()->user() != null && auth()->user()->fireStationID != null ){ $fireStation = fireStation::find(auth()->user()->fireStationID); if($fireStation-> creatorID == auth()->user()->id){ - return view('fireFightersAdd'); + //return view('fireFightersAdd'); + $ranks = DB::table('ranks')->pluck("rank","id"); + $unitFunctions = DB::table('unitFunctions')->pluck("unitFunction","id"); + return view('fireFightersAdd',compact('ranks'), compact('unitFunctions')); } else return fireFightersController::create(); } else return view("unit"); } @@ -55,6 +58,8 @@ class fireFightersController extends Controller 'PESEL' => new Pesel, 'phoneNumber' => 'required|digits:9', 'email' => 'required|email|unique:users', + 'rank' => 'required', + 'unitFunction' => 'required', ], [ 'required' => ':attribute jest wymagany(e).', @@ -77,8 +82,8 @@ class fireFightersController extends Controller 'surname' => $request-> surname, 'PESEL' => $request-> PESEL, 'phoneNumber' => $request-> phoneNumber, - 'functionID' => 1, - 'degreeID' => 1, + 'functionID' => $request-> unitFunction, + 'degreeID' => $request-> rank, 'number' => 'ABC123', 'fireStationID' => auth()->user()->fireStationID, 'creatorID' => auth()->user()-> id, diff --git a/database/migrations/2019_10_05_185538_create_ranks_table.php b/database/migrations/2019_10_05_185538_create_ranks_table.php new file mode 100644 index 0000000..dab8965 --- /dev/null +++ b/database/migrations/2019_10_05_185538_create_ranks_table.php @@ -0,0 +1,40 @@ +integer('id'); + $table->string('rank', 60); + }); + + + DB::table('ranks')->insert([ 'id' => '1', 'rank' => 'strażak' ]); + DB::table('ranks')->insert([ 'id' => '2', 'rank' => 'starszy strażak' ]); + DB::table('ranks')->insert([ 'id' => '3', 'rank' => 'dowódca roty' ]); + DB::table('ranks')->insert([ 'id' => '4', 'rank' => 'pomocnik dowódcy sekcji' ]); + DB::table('ranks')->insert([ 'id' => '5', 'rank' => 'dowódca sekcji' ]); + DB::table('ranks')->insert([ 'id' => '6', 'rank' => 'pomocnik dowódcy plutonu' ]); + DB::table('ranks')->insert([ 'id' => '7', 'rank' => 'dowódca plutonu' ]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('ranks'); + } +} diff --git a/database/migrations/2019_10_05_215707_create_unitFunctions_table.php b/database/migrations/2019_10_05_215707_create_unitFunctions_table.php new file mode 100644 index 0000000..6416a05 --- /dev/null +++ b/database/migrations/2019_10_05_215707_create_unitFunctions_table.php @@ -0,0 +1,39 @@ +integer('id'); + $table->string('unitFunction', 60); + }); + + DB::table('unitFunctions')->insert([ 'id' => '1', 'unitFunction' => 'naczelnik' ]); + DB::table('unitFunctions')->insert([ 'id' => '2', 'unitFunction' => 'zastępca naczelnika' ]); + DB::table('unitFunctions')->insert([ 'id' => '3', 'unitFunction' => 'skarbnik' ]); + DB::table('unitFunctions')->insert([ 'id' => '4', 'unitFunction' => 'sekretarz' ]); + DB::table('unitFunctions')->insert([ 'id' => '5', 'unitFunction' => 'prezes' ]); + DB::table('unitFunctions')->insert([ 'id' => '6', 'unitFunction' => 'przewodniczący komisji rewizyjnej' ]); + DB::table('unitFunctions')->insert([ 'id' => '7', 'unitFunction' => 'członek komisji rewizyjnej' ]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('unitFunctions'); + } +} diff --git a/resources/views/fireFightersAdd.blade.php b/resources/views/fireFightersAdd.blade.php index 28466a4..5a225dd 100644 --- a/resources/views/fireFightersAdd.blade.php +++ b/resources/views/fireFightersAdd.blade.php @@ -41,6 +41,26 @@ +
+ + +
+ +
+ + +
+