diff --git a/app/Http/Controllers/fireFightersController.php b/app/Http/Controllers/fireFightersController.php index 37afd87..b009925 100644 --- a/app/Http/Controllers/fireFightersController.php +++ b/app/Http/Controllers/fireFightersController.php @@ -17,8 +17,9 @@ class fireFightersController extends Controller // $users = user::where("fireStationID", auth()->user()->fireStationID)->get(); // $users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)->get(); $users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID) - ->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id') - ->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id') + ->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id') + ->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id') + ->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.email', 'users.statusID', 'ranks.rank', 'unitFunctions.unitFunction') ->get(); return view("fireFighters", ["users" => $users]); } else{ diff --git a/app/Http/Controllers/operationsController.php b/app/Http/Controllers/operationsController.php new file mode 100644 index 0000000..dcc1873 --- /dev/null +++ b/app/Http/Controllers/operationsController.php @@ -0,0 +1,72 @@ +user() != null && auth()->user()->fireStationID != null ){ + + return view('operation'); + } else{ + return view('operation'); + } + } + + public function addForm(){ + if(auth()->user() != null && auth()->user()->fireStationID != null ){ + //$fireStationID = auth()->user()->fireStationID; + // $fireFighters = User::pluck('fireStationID', $fireStationID); + $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get(); + return view("operationAdd", ["fireFighters" => $fireFighters]); + } else return view("unit"); + } + + + + public function editForm(){ + + } + + public function store(){ + $this->validate(request(),[ + 'operationDate' => 'required', + 'operationLocation' => 'required', + 'operationTarget' => 'required', + 'operationDangerType' => 'required', + 'operationDescription' => 'required', + 'operationLeader' => 'required', + 'operationDriver' => 'required', + ], + [ + 'required' => ':attribute jest wymagany(e)' + ]); + + $request = request(); + $operations = operations::create([ + 'operationDate' => $request-> operationDate, + 'location' => $request-> operationLocation, + 'target' => $request-> operationTarget, + 'dangerType' => $request-> operationDangerType, + 'description' => $request-> operationDescription, + 'commanderID' => $request-> operationLeader, + 'driverID' => $request-> operationDriver, + ]); + + return operationsController::create(); + } + + public function update(){ + + } +} diff --git a/app/operations.php b/app/operations.php new file mode 100644 index 0000000..9adafff --- /dev/null +++ b/app/operations.php @@ -0,0 +1,13 @@ +increments('id'); + $table->dateTime('operationDate'); + $table->string('location', 100); + $table->string('target', 100); + $table->string('dangerType', 100); + $table->string('description'); + $table->integer('commanderID'); + $table->integer('driverID'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('operations'); + } +} diff --git a/database/migrations/2019_11_16_195559_create_operationsTrucks_table.php b/database/migrations/2019_11_16_195559_create_operationsTrucks_table.php new file mode 100644 index 0000000..3af03d6 --- /dev/null +++ b/database/migrations/2019_11_16_195559_create_operationsTrucks_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->integer('operationID'); + $table->integer('truckID'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('operationsTrucks'); + } +} diff --git a/database/migrations/2019_11_16_195646_create_operationsMembers_table.php b/database/migrations/2019_11_16_195646_create_operationsMembers_table.php new file mode 100644 index 0000000..a7b2ce2 --- /dev/null +++ b/database/migrations/2019_11_16_195646_create_operationsMembers_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->integer('operationID'); + $table->integer('memberID'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('operationsMembers'); + } +} diff --git a/resources/views/fireFighters.blade.php b/resources/views/fireFighters.blade.php index aa63d1c..a1b7975 100644 --- a/resources/views/fireFighters.blade.php +++ b/resources/views/fireFighters.blade.php @@ -84,8 +84,8 @@ {{ $user->surname }} {{ $user->PESEL }} {{ $user->email }} - {{ $user->unitFunction }} - {{$user->rank}} + {{$user->unitFunction}} + {{$user->rank}} @if( $user->statusID == 0) Czynny @else Wyłączony @endif diff --git a/resources/views/operation.blade.php b/resources/views/operation.blade.php index bc21413..e004005 100644 --- a/resources/views/operation.blade.php +++ b/resources/views/operation.blade.php @@ -2,7 +2,7 @@ @section('left-menu') @parent