From 0713cd5a686fad590e275461f33244c3a1f67de7 Mon Sep 17 00:00:00 2001 From: Krzysztof Strzelecki Date: Sat, 1 Feb 2020 01:01:26 +0100 Subject: [PATCH] =?UTF-8?q?doko=C5=84czenie=20poziom=C3=B3w=20dost=C4=99pu?= =?UTF-8?q?=20i=20przekierowa=C5=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/DecorationsController.php | 4 ++-- app/Http/Controllers/EquipmentController.php | 8 ++++---- app/Http/Controllers/VehiclesController.php | 8 ++++---- app/Http/Controllers/operationsController.php | 8 ++++---- app/Http/Controllers/trainingsController.php | 8 ++++---- resources/views/equipment.blade.php | 10 ++++++++++ resources/views/operation.blade.php | 13 ++++++++++++- resources/views/vehicles.blade.php | 10 ++++++++++ 8 files changed, 50 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/DecorationsController.php b/app/Http/Controllers/DecorationsController.php index 65dbdf0..6e79290 100644 --- a/app/Http/Controllers/DecorationsController.php +++ b/app/Http/Controllers/DecorationsController.php @@ -21,7 +21,7 @@ function formatDate($date) class DecorationsController extends Controller { public function create($id){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik $awardedDecorations = DB::table('decorationsFirefighters')->where("decorationsFirefighters.firefighterID", '=', $id) ->whereNull('decorationsFirefighters.deleted_at') ->leftJoin('decorations', 'decorationsFirefighters.decorationID', '=', 'decorations.id') @@ -39,7 +39,7 @@ class DecorationsController extends Controller ->with(compact('decoration')); } else{ - return "Brak dostepu"; + return redirect()->to('/strazacy'); } } diff --git a/app/Http/Controllers/EquipmentController.php b/app/Http/Controllers/EquipmentController.php index 87563f0..69d5cb1 100644 --- a/app/Http/Controllers/EquipmentController.php +++ b/app/Http/Controllers/EquipmentController.php @@ -21,15 +21,15 @@ class EquipmentController extends Controller } public function addForm(){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik return view('equipmentAdd'); - } else return view("login"); + } else return redirect()->to('/sprzet'); } public function editForm($id) { - if(auth()->user() != null && auth()->user()->fireStationID != null ) + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ) //prezes,naczelnik { $equipment = DB::table('equipment')->where("id", $id)->first(); @@ -37,7 +37,7 @@ class EquipmentController extends Controller return view('equipmentEdit', ["equipment" => $equipment]); } else - return view("login"); + return redirect()->to('/sprzet'); } diff --git a/app/Http/Controllers/VehiclesController.php b/app/Http/Controllers/VehiclesController.php index ee9889f..fe6f52d 100644 --- a/app/Http/Controllers/VehiclesController.php +++ b/app/Http/Controllers/VehiclesController.php @@ -31,21 +31,21 @@ class VehiclesController extends Controller } public function addForm(){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik return view('vehiclesAdd'); - } else return view("login"); + } else return redirect()->to('/pojazdy'); } public function editForm($id) { - if(auth()->user() != null && auth()->user()->fireStationID != null ) + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ) //prezes,naczelnik { $vehicle = DB::table('vehicles')->where("id", $id)->first(); return view('vehiclesEdit', ["vehicle" => $vehicle]); } else - return "Brak dostepu"; + redirect()->to('/pojazdy'); } public function store(){ diff --git a/app/Http/Controllers/operationsController.php b/app/Http/Controllers/operationsController.php index 0401e8c..1b05dab 100644 --- a/app/Http/Controllers/operationsController.php +++ b/app/Http/Controllers/operationsController.php @@ -58,7 +58,7 @@ class operationsController extends Controller } public function addForm(){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get(); $vehicles = DB::table('vehicles')->where([ ["fireStationID", '=', auth()->user()->fireStationID], @@ -67,13 +67,13 @@ class operationsController extends Controller ]) ->get(); return view("operationAdd", ["fireFighters" => $fireFighters], ["vehicles" => $vehicles]); - } else return view("unit"); + } else return redirect()->to('/wyjazdy'); } public function editForm($id){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik // $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get(); $vehicles = DB::table('vehicles')->where([ @@ -118,7 +118,7 @@ class operationsController extends Controller // return "Brak dostepu"; // } } else{ - return view('unit'); + return redirect()->to('/wyjazdy'); } } diff --git a/app/Http/Controllers/trainingsController.php b/app/Http/Controllers/trainingsController.php index ae8e571..5f7ccbd 100644 --- a/app/Http/Controllers/trainingsController.php +++ b/app/Http/Controllers/trainingsController.php @@ -14,7 +14,7 @@ class trainingsController extends Controller { public function create(){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik $trainings = DB::table('trainings')->where("fireStationID", '=', auth()->user()->fireStationID) ->whereNull('deleted_at') ->paginate(10); @@ -32,7 +32,7 @@ class trainingsController extends Controller } return View::make("trainings")->with(compact( "trainings", "fireFighters")); } else{ - return view('trainings'); + return redirect()->to('/strazacy'); } } @@ -61,7 +61,7 @@ class trainingsController extends Controller public function addTrainingsFireFighters($id){ - if(auth()->user() != null && auth()->user()->fireStationID != null ){ + if(auth()->user() != null && auth()->user()->accessLevel() == 50 ){ //prezes,naczelnik $fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID ) ->leftJoin('trainingsFirefighters', function ($join) use($id){ $join->on('users.id', '=', 'trainingsFirefighters.firefighterID'); @@ -74,7 +74,7 @@ class trainingsController extends Controller ->whereNull('deleted_at')->first(); return View::make("trainingsAddFireFighters")->with(compact( "training", "fireFighters")); } else{ - return view('trainings'); + return redirect()->to('/strazacy'); } } diff --git a/resources/views/equipment.blade.php b/resources/views/equipment.blade.php index d83af61..0f18619 100644 --- a/resources/views/equipment.blade.php +++ b/resources/views/equipment.blade.php @@ -4,9 +4,15 @@ @section('left-menu') @parent + @if( auth()->check() ) + @if( auth()->user()->fireStationID != NULL) + @if(auth()->user()->accessLevel() == 50) + @endif + @endif + @endif @stop @section('center-area') @@ -25,7 +31,9 @@ Nazwa Ilość Param. charakterystyczny + @if(auth()->user()->accessLevel() == 50) Operacja + @endif @@ -38,10 +46,12 @@ {{ $item->name }} {{ $item->amount }} {{ $item->parameter }} + @if(auth()->user()->accessLevel() == 50) Edytuj + @endif @php diff --git a/resources/views/operation.blade.php b/resources/views/operation.blade.php index 1795bcc..5460103 100644 --- a/resources/views/operation.blade.php +++ b/resources/views/operation.blade.php @@ -3,9 +3,16 @@ @section('left-menu') - @parent