forked from s421507/eOSP2
75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use App\User;
|
|
use App\operations;
|
|
use App\operationsMembers;
|
|
use App\vehicle;
|
|
use App\operationsDrivers;
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class operationsController extends Controller
|
|
{
|
|
//
|
|
public function create(){
|
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
|
|
|
return view('operation');
|
|
} else{
|
|
return view('operation');
|
|
}
|
|
}
|
|
|
|
public function addForm(){
|
|
if(auth()->user() != null && auth()->user()->fireStationID != null ){
|
|
//$fireStationID = auth()->user()->fireStationID;
|
|
// $fireFighters = User::pluck('fireStationID', $fireStationID);
|
|
$fireFighters = DB::table('users')->where("fireStationID", "=", auth()->user()->fireStationID )->get();
|
|
$vehicles = DB::table('vehicles')->where("fireStationID", '=', auth()->user()->fireStationID)
|
|
->get();
|
|
return view("operationAdd", ["fireFighters" => $fireFighters], ["vehicles" => $vehicles]);
|
|
} else return view("unit");
|
|
}
|
|
|
|
|
|
|
|
public function editForm(){
|
|
|
|
}
|
|
|
|
public function store(){
|
|
$this->validate(request(),[
|
|
'operationDate' => 'required',
|
|
'operationLocation' => 'required',
|
|
'operationTarget' => 'required',
|
|
'operationDangerType' => 'required',
|
|
'operationDescription' => 'required',
|
|
'operationLeader' => 'required',
|
|
'operationDriver' => 'required',
|
|
],
|
|
[
|
|
'required' => ':attribute jest wymagany(e)'
|
|
]);
|
|
|
|
$request = request();
|
|
$operations = operations::create([
|
|
'operationDate' => $request-> operationDate,
|
|
'location' => $request-> operationLocation,
|
|
'target' => $request-> operationTarget,
|
|
'dangerType' => $request-> operationDangerType,
|
|
'description' => $request-> operationDescription,
|
|
'commanderID' => $request-> operationLeader,
|
|
]);
|
|
|
|
return operationsController::create();
|
|
}
|
|
|
|
public function update(){
|
|
|
|
}
|
|
}
|