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 @@
Opis {{$operation->id}} | +|||||||
Opis Akcji | |||||||
{{$operation->description}} | |||||||
Pojazdy | +Kierowcy | +||||||
{{$truck->name}} {{$truck->codename }} {{$truck->brand}} {{$truck->registrationNumber}} | +{{$truck->driverName }} {{ $truck->driverSurname}} | +||||||
Członkowie Akcji | +Transport Własny | ||||||
{{$fireFighter->name}} {{$fireFighter->surname }} | +{{($fireFighter->privateTransport == 1) ? "Tak" : "Nie"}} | +