From c69bdaf0537fcda76eebd86412f1457e5fa4fe4c Mon Sep 17 00:00:00 2001 From: czup Date: Wed, 29 Jan 2020 01:57:19 +0100 Subject: [PATCH] =?UTF-8?q?Dodanie=20paginacji=20oraz=20poprawienie=20wido?= =?UTF-8?q?k=C3=B3w=20wi=C4=99kszo=C5=9Bci=20tabel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EquipmentController.php | 22 +-- .../Controllers/fireFightersController.php | 2 +- app/Http/Controllers/trainingsController.php | 11 +- ...2_add_soft_deletes_to_operations_table.php | 0 resources/views/decorations.blade.php | 45 +++--- resources/views/equipment.blade.php | 72 ++++++++-- resources/views/equipmentAdd.blade.php | 4 +- resources/views/fireFighters.blade.php | 81 ++++++----- resources/views/fireStationEdit.blade.php | 14 +- resources/views/operation.blade.php | 12 +- resources/views/operationEdit.blade.php | 4 +- resources/views/trainings.blade.php | 133 ++++++++++++------ .../views/trainingsAddFireFighters.blade.php | 45 +++--- routes/web.php | 3 +- 14 files changed, 288 insertions(+), 160 deletions(-) rename database/migrations/{x => }/2020_01_22_004052_add_soft_deletes_to_operations_table.php (100%) diff --git a/app/Http/Controllers/EquipmentController.php b/app/Http/Controllers/EquipmentController.php index 871e02e..d95868b 100644 --- a/app/Http/Controllers/EquipmentController.php +++ b/app/Http/Controllers/EquipmentController.php @@ -12,7 +12,7 @@ class EquipmentController extends Controller if(auth()->user() != null && auth()->user()->fireStationID != null ){ $equipment = DB::table('equipment')->where("fireStationID", '=', auth()->user()->fireStationID) - ->whereNull('deleted_at')->get(); + ->whereNull('deleted_at')->paginate(10); return view("equipment", ["equipment" => $equipment]); } else{ return view('equipment'); @@ -21,9 +21,9 @@ class EquipmentController extends Controller } public function addForm(){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->fireStationID != null ){ return view('equipmentAdd'); - + } else return view("login"); } @@ -33,12 +33,12 @@ class EquipmentController extends Controller { $equipment = DB::table('equipment')->where("id", $id)->first(); - + return view('equipmentEdit', ["equipment" => $equipment]); - } + } else return view("login"); - + } public function store(){ @@ -57,7 +57,7 @@ class EquipmentController extends Controller $equipment = equipment::create([ 'fireStationID' => auth()->user()->fireStationID, 'name' => $request-> name, - 'amount' => $request-> amount, + 'amount' => $request-> amount, 'parameter' => $request-> parameter, ]); @@ -79,7 +79,7 @@ class EquipmentController extends Controller $request = request(); $equipment = equipment::find( $request->equipmentID); $equipment-> name = $request-> name; - $equipment-> amount = $request-> amount; + $equipment-> amount = $request-> amount; $equipment-> parameter = $request-> parameter; $equipment->save(); @@ -89,7 +89,9 @@ class EquipmentController extends Controller public function destroy($id) { equipment::where('id',$id)->delete(); - - return redirect()->to('/sprzet'); + + return response()->json([ + 'success' => 'Record deleted successfully!' + ]); } } diff --git a/app/Http/Controllers/fireFightersController.php b/app/Http/Controllers/fireFightersController.php index b009925..1677613 100644 --- a/app/Http/Controllers/fireFightersController.php +++ b/app/Http/Controllers/fireFightersController.php @@ -20,7 +20,7 @@ class fireFightersController extends Controller ->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(); + ->paginate(10); return view("fireFighters", ["users" => $users]); } else{ return view('fireFighters'); diff --git a/app/Http/Controllers/trainingsController.php b/app/Http/Controllers/trainingsController.php index 62354a1..1d90a81 100644 --- a/app/Http/Controllers/trainingsController.php +++ b/app/Http/Controllers/trainingsController.php @@ -16,7 +16,8 @@ class trainingsController extends Controller if(auth()->user() != null && auth()->user()->fireStationID != null ){ $trainings = DB::table('trainings')->where("fireStationID", '=', auth()->user()->fireStationID) - ->whereNull('deleted_at')->get(); + ->whereNull('deleted_at') + ->paginate(10); $fireFighters = array(); foreach($trainings as $training) { @@ -66,7 +67,7 @@ class trainingsController extends Controller $join->where('trainingsFirefighters.trainingID', '=', $id); }) ->select('trainingsFirefighters.*', 'users.name', 'users.surname', 'users.id as userID') - ->get(); + ->paginate(10); $training = DB::table('trainings')->where("id", '=', $id) ->whereNull('deleted_at')->first(); @@ -158,9 +159,11 @@ class trainingsController extends Controller public function destroy($id) { - trainings::where('id',$id)->delete(); + trainings::find($id)->delete($id); - return redirect()->to('/szkolenia'); + return response()->json([ + 'success' => 'Record deleted successfully!' + ]); } public function trainingsRename(Request $request){ diff --git a/database/migrations/x/2020_01_22_004052_add_soft_deletes_to_operations_table.php b/database/migrations/2020_01_22_004052_add_soft_deletes_to_operations_table.php similarity index 100% rename from database/migrations/x/2020_01_22_004052_add_soft_deletes_to_operations_table.php rename to database/migrations/2020_01_22_004052_add_soft_deletes_to_operations_table.php diff --git a/resources/views/decorations.blade.php b/resources/views/decorations.blade.php index 00921d8..2b553d2 100644 --- a/resources/views/decorations.blade.php +++ b/resources/views/decorations.blade.php @@ -15,27 +15,32 @@ @else @if(count($awardedDecorations) > 0)

- - - - - - - - @foreach($awardedDecorations as $awardedDecoration) - - - - - - +
{{ $firefighter->name }} {{ $firefighter->surname }} - odznaczenia
OdznaczenieData przyznania
{{ $awardedDecoration->decorationName }}{{ $awardedDecoration->dateOfAward }} - {{ csrf_field() }} - @method('DELETE') - -
+ + + - @endforeach -
{{ $firefighter->name }} {{ $firefighter->surname }} - odznaczenia
+ + + + Odznaczenie + Data przyznania + Operacja + @foreach($awardedDecorations as $awardedDecoration) + +

+ {{ $awardedDecoration->decorationName }} + {{ $awardedDecoration->dateOfAward }} + + {{ csrf_field() }} + @method('DELETE') + + +
+ + @endforeach + +

@else {{ $firefighter->name }} {{ $firefighter->surname }} nie posiada żadnych odznaczeń. diff --git a/resources/views/equipment.blade.php b/resources/views/equipment.blade.php index 794563a..758b9ff 100644 --- a/resources/views/equipment.blade.php +++ b/resources/views/equipment.blade.php @@ -1,5 +1,6 @@ @extends('layout.app') + @section('left-menu') @parent