This commit is contained in:
czup 2019-11-23 15:01:59 +01:00
parent cb9965cd95
commit 617d8e1b42
12 changed files with 292 additions and 9 deletions

View File

@ -19,6 +19,7 @@ class fireFightersController extends Controller
$users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID) $users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)
->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id') ->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id')
->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id') ->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id')
->select('users.id','users.name', 'users.surname', 'users.PESEL', 'users.email', 'users.statusID', 'ranks.rank', 'unitFunctions.unitFunction')
->get(); ->get();
return view("fireFighters", ["users" => $users]); return view("fireFighters", ["users" => $users]);
} else{ } else{

View File

@ -0,0 +1,72 @@
<?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(){
}
}

13
app/operations.php Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class operations extends Model
{
//
protected $primaryKey = 'id';
protected $fillable = ['operationDate', 'location', 'target', 'dangerType', 'description', 'commanderID', 'driverID'];
}

13
app/operationsMembers.php Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class operationsMembers extends Model
{
//
protected $primaryKey = 'id';
protected $fillable = ['operationID', 'memberID'];
}

13
app/operationsTrucks.php Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class operationsTrucks extends Model
{
//
protected $primaryKey = 'id';
protected $fillable = ['operationID', 'truckID'];
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOperationsTable extends Migration
{
/**
* Run the migrations.5
*
* @return void
*/
public function up()
{
Schema::create('operations', function (Blueprint $table) {
$table->increments('id');
$table->dateTime('operationDate');
$table->string('location', 100);
$table->string('target', 100);
$table->string('dangerType', 100);
$table->string('description');
$table->integer('commanderID');
$table->integer('driverID');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('operations');
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOperationsTrucksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('operationsTrucks', function (Blueprint $table) {
$table->increments('id');
$table->integer('operationID');
$table->integer('truckID');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('operationsTrucks');
}
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateOperationsMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('operationsMembers', function (Blueprint $table) {
$table->increments('id');
$table->integer('operationID');
$table->integer('memberID');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('operationsMembers');
}
}

View File

@ -2,7 +2,7 @@
@section('left-menu') @section('left-menu')
@parent<ul> @parent<ul>
<a href="?addOperation"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a> <a href="wyjazdy/add"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
<li>Edytuj<img src="img/left_menu_icon/edit.png"></li> <li>Edytuj<img src="img/left_menu_icon/edit.png"></li>
<li>Usuń<img src="img/left_menu_icon/delete.png"></li> <li>Usuń<img src="img/left_menu_icon/delete.png"></li>

View File

@ -0,0 +1,67 @@
@extends('layout.app')
@section('left-menu')
@parent<ul>
<a href="?addOperation"><li>Dodaj<img src="img/left_menu_icon/add.png"></li></a>
<li>Edytuj<img src="img/left_menu_icon/edit.png"></li>
<li>Usuń<img src="img/left_menu_icon/delete.png"></li>
</ul>
@stop
@section('center-area')
@parent
Strona w budowie - dodawanie
<form method="POST" action="/wyjazdy">
{{ csrf_field() }}
<div class="form-group">
<label for="date">Data wyjazdu: </label>
<input type="datetime-local" id="operationDate" name="operationDate">
</div>
<div class="form-group">
<label for="location">Miejsce akcji:</label>
<input type="text" class="form-control" id="operationLocation" name="operationLocation">
</div>
<div class="form-group">
<label for="location">Cel wyjazdu:</label>
<input type="text" class="form-control" id="operationTarget" name="operationTarget">
</div>
<div class="form-group">
<label for="location">Rodzaj zagrożenia:</label>
<input type="text" class="form-control" id="operationDangerType" name="operationDangerType">
</div>
<div class="form-group">
<label for="location">Opis akcji:</label>
<textarea class="form-control" id="'operationDescription" name="operationDescription">Enter text here...</textarea>
</div>
<div class=form-group">
<label for="location">Dowodzący:</label>
<select name="operationLeader" class="form-control">
<option value="">--- Wybierz dowódcę ---</option>
@foreach ($fireFighters as $fireFighter)
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
@endforeach
</select>
</div>
<div class=form-group">
<label for="location">Kierowca:</label>
<select name="operationDriver" class="form-control">
<option value="">--- Wybierz kierowcę ---</option>
@foreach ($fireFighters as $fireFighter)
<option value="{{$fireFighter->id}}">{{ $fireFighter->name }} {{$fireFighter->surname }}</option>
@endforeach
</select>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Dodaj</button>
</div>
</div>
@include('inc.formerrors')
</form>
@stop

View File

@ -30,9 +30,9 @@ Route::get('/pojazdy', function(){
return view('vehicles'); return view('vehicles');
}); });
Route::get('/wyjazdy', function(){ Route::get('/wyjazdy', 'operationsController@create');
return view('operation'); Route::get('/wyjazdy/add/', 'operationsController@addForm');
}); Route::post('/wyjazdy', 'operationsController@store');
Route::get('/register', 'RegistrationController@create'); Route::get('/register', 'RegistrationController@create');
Route::post('/register', 'RegistrationController@store'); Route::post('/register', 'RegistrationController@store');