forked from s421507/eOSP2
Wyjazdy
This commit is contained in:
parent
cb9965cd95
commit
617d8e1b42
@ -17,8 +17,9 @@ class fireFightersController extends Controller
|
||||
// $users = user::where("fireStationID", auth()->user()->fireStationID)->get();
|
||||
// $users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)->get();
|
||||
$users = DB::table('users')->where("fireStationID", '=', auth()->user()->fireStationID)
|
||||
->leftJoin('ranks', 'users.degreeID', '=', 'ranks.id')
|
||||
->leftJoin('unitFunctions', 'users.functionID', '=', 'unitFunctions.id')
|
||||
->leftJoin('ranks', 'users.degreeID', '=', 'ranks.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();
|
||||
return view("fireFighters", ["users" => $users]);
|
||||
} else{
|
||||
|
72
app/Http/Controllers/operationsController.php
Normal file
72
app/Http/Controllers/operationsController.php
Normal 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
13
app/operations.php
Normal 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
13
app/operationsMembers.php
Normal 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
13
app/operationsTrucks.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class operationsTrucks extends Model
|
||||
{
|
||||
//
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $fillable = ['operationID', 'truckID'];
|
||||
}
|
@ -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');
|
||||
}
|
||||
}
|
@ -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');
|
||||
}
|
||||
}
|
@ -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');
|
||||
}
|
||||
}
|
@ -84,8 +84,8 @@
|
||||
<td id="userSurname{{ $user->id }}">{{ $user->surname }}</td>
|
||||
<td id="userPESEL{{ $user->id }}">{{ $user->PESEL }}</td>
|
||||
<td id="userEmail{{ $user->id }}">{{ $user->email }}</td>
|
||||
<td id="userFunction{{ $user->id }}">{{ $user->unitFunction }}</td>
|
||||
<td id="userDegree{{ $user->id }}">{{$user->rank}}</td>
|
||||
<td id="userFunction{{ $user->id }}"> {{$user->unitFunction}} </td>
|
||||
<td id="userDegree{{ $user->id }}"> {{$user->rank}}</td>
|
||||
<td id="userStatus{{ $user->id }}">@if( $user->statusID == 0) Czynny @else Wyłączony @endif</td>
|
||||
<td><a href="{{ URL::asset('strazacy/edit/'.$user->id) }}"><input type="button" onclick="" value="Edytuj"> </a></td>
|
||||
</tr>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
@section('left-menu')
|
||||
@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>Usuń<img src="img/left_menu_icon/delete.png"></li>
|
||||
|
||||
@ -13,4 +13,4 @@
|
||||
@parent
|
||||
Strona w budowie
|
||||
|
||||
@stop
|
||||
@stop
|
||||
|
67
resources/views/operationAdd.blade.php
Normal file
67
resources/views/operationAdd.blade.php
Normal 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
|
@ -30,9 +30,9 @@ Route::get('/pojazdy', function(){
|
||||
return view('vehicles');
|
||||
});
|
||||
|
||||
Route::get('/wyjazdy', function(){
|
||||
return view('operation');
|
||||
});
|
||||
Route::get('/wyjazdy', 'operationsController@create');
|
||||
Route::get('/wyjazdy/add/', 'operationsController@addForm');
|
||||
Route::post('/wyjazdy', 'operationsController@store');
|
||||
|
||||
Route::get('/register', 'RegistrationController@create');
|
||||
Route::post('/register', 'RegistrationController@store');
|
||||
|
Loading…
Reference in New Issue
Block a user