73 lines
2.0 KiB
PHP
73 lines
2.0 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers;
|
||
|
|
||
|
|
||
|
use App\User;
|
||
|
use App\operations;
|
||
|
use App\operationsMembers;
|
||
|
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();
|
||
|
return view("operationAdd", ["fireFighters" => $fireFighters]);
|
||
|
} 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,
|
||
|
'driverID' => $request-> operationDriver,
|
||
|
]);
|
||
|
|
||
|
return operationsController::create();
|
||
|
}
|
||
|
|
||
|
public function update(){
|
||
|
|
||
|
}
|
||
|
}
|