eOSP2/app/Http/Controllers/operationsController.php

73 lines
2.0 KiB
PHP
Raw Normal View History

2019-11-23 15:01:59 +01:00
<?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(){
}
}