diff --git a/app/Http/Controllers/operationsController.php b/app/Http/Controllers/operationsController.php index 14d0a0c..032d9ae 100644 --- a/app/Http/Controllers/operationsController.php +++ b/app/Http/Controllers/operationsController.php @@ -24,7 +24,30 @@ class operationsController extends Controller ->select('operations.id', 'operations.operationDate', 'operations.location', 'operations.target', 'operations.dangerType', 'operations.description', 'operations.commanderID', 'operations.fireStationID', 'users.name', 'users.surname') ->get(); - return view('operation', ["operations" => $operations]); + foreach($operations as $operation){ + $id =$operation->id; + $fireFighters[$id] = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID ) + ->leftJoin('operationsMembers', function ($join) use($id){ + $join->on('users.id', '=', 'operationsMembers.memberID'); + $join->where('operationsMembers.operationID', '=', $id); + }) + ->select('users.*', 'operationsMembers.memberID', 'operationsMembers.privateTransport') + ->get(); + + $trucks[$id] = DB::table('vehicles')->where("vehicles.fireStationID", "=", auth()->user()->fireStationID ) + ->leftJoin('operationsTrucks', function ($join) use($id){ + $join->on('vehicles.id', '=', 'operationsTrucks.truckID'); + $join->where('operationsTrucks.operationID', '=', $id); + }) + ->leftJoin('users', 'operationsTrucks.driverID', '=', 'users.id') + ->select('vehicles.*', 'operationsTrucks.truckID', 'operationsTrucks.driverID', 'users.name as driverName', 'users.surname as driverSurname') + ->get(); + } + + + +// return view('operation', ["operations" => $operations], ["fireFighters" => $fireFighters], ["trucks" => $trucks]); + return View::make('/operation')->with(compact('operations', 'fireFighters', 'trucks')); } else{ return view('operation'); } @@ -179,8 +202,8 @@ class operationsController extends Controller for($count = 0; $count < count($operationDriver); $count++){ $operationsTrucks = operationsTrucks::create([ 'operationID' => $request->operationID, - 'truckID' => $operationDriver[$count], - 'driverID' => $operationVehicle[$count] + 'truckID' => $operationVehicle[$count], + 'driverID' => $operationDriver[$count] ]); } diff --git a/resources/views/operation.blade.php b/resources/views/operation.blade.php index d084bf5..564dee3 100644 --- a/resources/views/operation.blade.php +++ b/resources/views/operation.blade.php @@ -35,24 +35,54 @@ - + + +
- - + + - + + + + + + + + @foreach($trucks[$operation->id] as $truck) + @if($truck->truckID != null) + + + + + @endif + @endforeach + + + + + @foreach($fireFighters[$operation->id] as $fireFighter) + @if($fireFighter->memberID != null) + + + + + @endif + @endforeach
Opis {{$operation->id}}
Opis Akcji
{{$operation->description}}
PojazdyKierowcy
{{$truck->name}} {{$truck->codename }} {{$truck->brand}} {{$truck->registrationNumber}}{{$truck->driverName }} {{ $truck->driverSurname}}
Członkowie AkcjiTransport Własny
{{$fireFighter->name}} {{$fireFighter->surname }}{{($fireFighter->privateTransport == 1) ? "Tak" : "Nie"}}
+
+ @endforeach - " + @endif @else @@ -66,10 +96,10 @@ if( $('#more'+operationID).val() == "Więcej"){ $('#more'+operationID).val("Ukryj"); - $("#moreInformation"+operationID).css('display', 'block'); + $("#moreInformation"+operationID).css('visibility', 'visible'); } else{ $('#more'+operationID).val("Więcej"); - $("#moreInformation"+operationID).css('display', 'none'); + $("#moreInformation"+operationID).css('visibility', 'collapse'); } }