diff --git a/app/Http/Controllers/EquipmentController.php b/app/Http/Controllers/EquipmentController.php new file mode 100644 index 0000000..1ba340d --- /dev/null +++ b/app/Http/Controllers/EquipmentController.php @@ -0,0 +1,88 @@ +user() != null && auth()->user()->fireStationID != null ){ + $equipment = DB::table('equipment')->where("fireStationID", '=', auth()->user()->fireStationID) + ->get(); + return view("equipment", ["equipment" => $equipment]); + } else{ + return view('equipment'); + } + + } + + public function addForm(){ + if(auth()->user() != null && auth()->user()->fireStationID != null ){ + return view('equipmentAdd'); + + } else return view("login"); + } + + public function editForm($id) + { + if(auth()->user() != null && auth()->user()->fireStationID != null ) + { + + $equipment = DB::table('equipment')->where("id", $id)->first(); + + return view('equipmentEdit', ["equipment" => $equipment]); + } + else + return view("login"); + + } + + public function store(){ + $this->validate(request(), [ + + 'name' => 'required', + 'amount' => 'required|numeric', + ], + [ + 'required' => ':attribute jest wymagany(a).', + 'numeric' => ':attribute powinna zawierać tylko cyfry.', + ]); + + + $request = request(); + $equipment = equipment::create([ + 'fireStationID' => auth()->user()->fireStationID, + 'name' => $request-> name, + 'amount' => $request-> amount, + 'parameter' => $request-> parameter, + ]); + + return redirect()->to('/sprzet'); + } + + public function update(){ + $this->validate(request(), [ + + 'name' => 'required', + 'amount' => 'required|numeric', + ], + [ + 'required' => ':attribute jest wymagany(a).', + 'numeric' => ':attribute powinna zawierać tylko cyfry.' + ]); + + + $request = request(); + $equipment = equipment::find( $request->equipmentID); + $equipment-> name = $request-> name; + $equipment-> amount = $request-> amount; + $equipment-> parameter = $request-> parameter; + $equipment->save(); + + return EquipmentController::create(); + } +} diff --git a/app/equipment.php b/app/equipment.php new file mode 100644 index 0000000..7b1c257 --- /dev/null +++ b/app/equipment.php @@ -0,0 +1,16 @@ +increments('id'); + $table->integer('fireStationID'); + $table->string('name', 45); + $table->integer('amount'); + $table->string('parameter', 45)->nullable(); + $table->boolean('deleted')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('equipment'); + } +} diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 2369461..63ecebe 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -161,6 +161,7 @@ return [ 'unitName' => 'nazwa jednostki', 'longitude' => 'długość geograficzna', 'latitude' => 'szerokość geograficzna', + 'amount' => 'ilość' ], diff --git a/resources/views/depot.blade.php b/resources/views/depot.blade.php index 82fb773..2b675af 100644 --- a/resources/views/depot.blade.php +++ b/resources/views/depot.blade.php @@ -3,14 +3,16 @@ @section('left-menu') @parent @stop @section('center-area') @parent Strona w budowie -

Zawarte będą tutaj informację o umundurowaniu oraz sprzęcie jaki jest na wyposarzeniu strażnicy oraz informacje gdzie umundurowanie się znajduje(druhowie mundury koszarowe oraz galowe mają w w domach, informacja ta pozwoli na sprawdzenie np jakie są braki w umundurowaniu)

+

Zawarte będą tutaj informacje o umundurowaniu oraz sprzęcie jaki jest na wyposażeniu strażnicy oraz informacje gdzie umundurowanie się znajduje(druhowie mundury koszarowe oraz galowe mają w w domach, informacja ta pozwoli na sprawdzenie np jakie są braki w umundurowaniu).

+ + @stop \ No newline at end of file diff --git a/resources/views/equipment.blade.php b/resources/views/equipment.blade.php new file mode 100644 index 0000000..2077ca6 --- /dev/null +++ b/resources/views/equipment.blade.php @@ -0,0 +1,40 @@ +@extends('layout.app') + +@section('left-menu') + @parent + +@stop + +@section('center-area') + @parent + + @if( auth()->check()) + @if( auth()->user()->fireStationID == NULL) + Jednostka nie istnieje + @else + + + + + + + @foreach($equipment as $item) + + + + + + + @endforeach +
NazwaIlośćParam. charakterystyczny
{{ $item->name }}{{ $item->amount }}{{ $item->parameter }}
+ + @endif + @else + Brak autoryzacji + @endif + +@stop \ No newline at end of file diff --git a/resources/views/equipmentAdd.blade.php b/resources/views/equipmentAdd.blade.php new file mode 100644 index 0000000..fb79b7e --- /dev/null +++ b/resources/views/equipmentAdd.blade.php @@ -0,0 +1,36 @@ +@extends('layout.app') + +@section('left-menu') + @parent + +@stop + +@section('center-area') + @parent +
+ {{ csrf_field() }} +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ @include('inc.formerrors') +
+@stop diff --git a/resources/views/equipmentEdit.blade.php b/resources/views/equipmentEdit.blade.php new file mode 100644 index 0000000..123f5ba --- /dev/null +++ b/resources/views/equipmentEdit.blade.php @@ -0,0 +1,38 @@ +@extends('layout.app') + +@section('left-menu') + @parent + +@stop + +@section('center-area') + @parent +
+ {{ csrf_field() }} + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ @include('inc.formerrors') +
+@stop \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 59c56f2..e63c4dd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -63,6 +63,12 @@ Route::get('/pojazdy/edit/{id}', 'VehiclesController@editForm'); Route::post('/pojazdy/edit', 'VehiclesController@update'); +Route::get('/sprzet', 'EquipmentController@create'); +Route::get('/sprzet/add', 'EquipmentController@addForm'); +Route::post('/sprzet', 'EquipmentController@store'); +Route::get('/sprzet/edit/{id}', 'EquipmentController@editForm'); +Route::post('/sprzet/edit', 'EquipmentController@update'); + Route::get('register/verify/{confirmationCode}', [ 'as' => 'confirmation_path', 'uses' => 'RegistrationController@confirm'