From 2513a41e0a64c09b48881bab19262dee1ec1911b Mon Sep 17 00:00:00 2001 From: czup Date: Wed, 15 Jan 2020 11:47:40 +0100 Subject: [PATCH] =?UTF-8?q?Jednostka=20-=20pobieranie=20ilo=C5=9Bci=20akty?= =?UTF-8?q?wnych=20cz=C5=82onk=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/fireStationController.php | 17 ++++++--- app/Http/Controllers/operationsController.php | 13 ++++++- app/operations.php | 3 -- resources/views/operationAdd.blade.php | 2 +- resources/views/operationEdit.blade.php | 37 +++++++++++-------- resources/views/unit.blade.php | 2 +- 6 files changed, 47 insertions(+), 27 deletions(-) diff --git a/app/Http/Controllers/fireStationController.php b/app/Http/Controllers/fireStationController.php index 817bd6a..4942067 100644 --- a/app/Http/Controllers/fireStationController.php +++ b/app/Http/Controllers/fireStationController.php @@ -6,16 +6,21 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\fireStation; use DB; +use Illuminate\Support\Facades\View; class fireStationController extends Controller { public function create(){ if(auth()->user() != null && auth()->user()->fireStationID != null ){ + $users = DB::table('users') + ->where('fireStationID', '=', auth()->user()->fireStationID) + ->count(); $fireStation = fireStation::find(auth()->user()->fireStationID); - return view('unit', ["fireStation" => $fireStation]); + return View::make('unit')->with(compact('fireStation', 'users')); + } else{ $voivodeships = DB::table('wojewodztwa')->pluck("name","id"); - return view('unit',compact('voivodeships')); + return view('unit',compact('voivodeships')); } } @@ -24,12 +29,12 @@ class fireStationController extends Controller if(auth()->user() != null && auth()->user()->fireStationID != null ) { $id = auth()->user()->fireStationID; - $fireStation = DB::table('fireStations')->where("id", $id)->first(); - $voivodeships = DB::table('wojewodztwa')->pluck("name","id"); + $fireStation = DB::table('fireStations')->where("id", $id)->first(); + $voivodeships = DB::table('wojewodztwa')->pluck("name","id"); return view('fireStationEdit', ["fireStation" => $fireStation], compact('voivodeships')); - } + } else - return "Brak dostępu"; + return "Brak dostępu"; } public function store() diff --git a/app/Http/Controllers/operationsController.php b/app/Http/Controllers/operationsController.php index eb68878..7994efc 100644 --- a/app/Http/Controllers/operationsController.php +++ b/app/Http/Controllers/operationsController.php @@ -85,9 +85,20 @@ class operationsController extends Controller }) ->select('users.*', 'operationsMembers.memberID', 'operationsMembers.privateTransport') ->get(); + + + $operationsTrucks = 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(); + // if($userFireStation == $fireFighterFireStation && auth()->user()->id == $fireStationCreatorId) { // return view('operationEdit', ["operation" => $operation], ["fireFighters" => $fireFighters], ["operationMembers" => $operationMembers] ); - return View::make('/operationEdit')->with(compact('fireFighters','operation', 'operationMembers', 'vehicles')); + return View::make('/operationEdit')->with(compact('fireFighters','operation', 'operationMembers', 'vehicles', 'operationsTrucks')); // } else{ // return "Brak dostepu"; // } diff --git a/app/operations.php b/app/operations.php index 5b9aba9..bf4360a 100644 --- a/app/operations.php +++ b/app/operations.php @@ -12,7 +12,4 @@ class operations extends Model protected $fillable = ['fireStationID', 'operationDate', 'location', 'target', 'dangerType', 'description', 'commanderID']; - public function getFromOperationsAttribute($value){ - return \Carbon\Carbon::parse($value)->format('d-m-Y'); - } } diff --git a/resources/views/operationAdd.blade.php b/resources/views/operationAdd.blade.php index 0411458..eb2d8ad 100644 --- a/resources/views/operationAdd.blade.php +++ b/resources/views/operationAdd.blade.php @@ -16,7 +16,7 @@ {{ csrf_field() }}
- +
diff --git a/resources/views/operationEdit.blade.php b/resources/views/operationEdit.blade.php index d9b7d03..51a1246 100644 --- a/resources/views/operationEdit.blade.php +++ b/resources/views/operationEdit.blade.php @@ -51,23 +51,31 @@
+ @foreach($operationsTrucks as $operationTruck) + {{$operationTruck->driverName}} + @endforeach
-{{-- --}} -{{-- --}} -{{-- --}} -{{-- --}} + @foreach($operationsTrucks as $operationTruck) +
+ {{$operationTruck->driverName}} + + + + +
+ @endforeach
@@ -104,7 +112,6 @@ $(document).ready(function(){ - {{--document.getElementById("operationDate").defaultValue = "{{\Carbon\Carbon::parse($operation->operationDate)->format('d.m.Y H:i')}}";--}} var count = 1; dynamic_field(count); diff --git a/resources/views/unit.blade.php b/resources/views/unit.blade.php index f3db799..ff7aab7 100644 --- a/resources/views/unit.blade.php +++ b/resources/views/unit.blade.php @@ -29,7 +29,7 @@

Telefon: {{ $fireStation-> phoneNumber }}

E-mail: {{ $fireStation-> email }}


-

Liczba członków: 40

+

Liczba członków: {{$users}}

@endif