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)