1
0
forked from s421507/eOSP2

dodanie stopni strażackich i funkcji w jednostce

This commit is contained in:
Krzysztof Strzelecki 2019-10-06 00:56:23 +02:00
parent e00f575f94
commit 8494c67377
4 changed files with 107 additions and 3 deletions

View File

@ -28,7 +28,10 @@ class fireFightersController extends Controller
if(auth()->user() != null && auth()->user()->fireStationID != null ){
$fireStation = fireStation::find(auth()->user()->fireStationID);
if($fireStation-> creatorID == auth()->user()->id){
return view('fireFightersAdd');
//return view('fireFightersAdd');
$ranks = DB::table('ranks')->pluck("rank","id");
$unitFunctions = DB::table('unitFunctions')->pluck("unitFunction","id");
return view('fireFightersAdd',compact('ranks'), compact('unitFunctions'));
} else return fireFightersController::create();
} else return view("unit");
}
@ -55,6 +58,8 @@ class fireFightersController extends Controller
'PESEL' => new Pesel,
'phoneNumber' => 'required|digits:9',
'email' => 'required|email|unique:users',
'rank' => 'required',
'unitFunction' => 'required',
],
[
'required' => ':attribute jest wymagany(e).',
@ -77,8 +82,8 @@ class fireFightersController extends Controller
'surname' => $request-> surname,
'PESEL' => $request-> PESEL,
'phoneNumber' => $request-> phoneNumber,
'functionID' => 1,
'degreeID' => 1,
'functionID' => $request-> unitFunction,
'degreeID' => $request-> rank,
'number' => 'ABC123',
'fireStationID' => auth()->user()->fireStationID,
'creatorID' => auth()->user()-> id,

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateRanksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ranks', function (Blueprint $table) {
$table->integer('id');
$table->string('rank', 60);
});
DB::table('ranks')->insert([ 'id' => '1', 'rank' => 'strażak' ]);
DB::table('ranks')->insert([ 'id' => '2', 'rank' => 'starszy strażak' ]);
DB::table('ranks')->insert([ 'id' => '3', 'rank' => 'dowódca roty' ]);
DB::table('ranks')->insert([ 'id' => '4', 'rank' => 'pomocnik dowódcy sekcji' ]);
DB::table('ranks')->insert([ 'id' => '5', 'rank' => 'dowódca sekcji' ]);
DB::table('ranks')->insert([ 'id' => '6', 'rank' => 'pomocnik dowódcy plutonu' ]);
DB::table('ranks')->insert([ 'id' => '7', 'rank' => 'dowódca plutonu' ]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ranks');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUnitFunctionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('unitFunctions', function (Blueprint $table) {
$table->integer('id');
$table->string('unitFunction', 60);
});
DB::table('unitFunctions')->insert([ 'id' => '1', 'unitFunction' => 'naczelnik' ]);
DB::table('unitFunctions')->insert([ 'id' => '2', 'unitFunction' => 'zastępca naczelnika' ]);
DB::table('unitFunctions')->insert([ 'id' => '3', 'unitFunction' => 'skarbnik' ]);
DB::table('unitFunctions')->insert([ 'id' => '4', 'unitFunction' => 'sekretarz' ]);
DB::table('unitFunctions')->insert([ 'id' => '5', 'unitFunction' => 'prezes' ]);
DB::table('unitFunctions')->insert([ 'id' => '6', 'unitFunction' => 'przewodniczący komisji rewizyjnej' ]);
DB::table('unitFunctions')->insert([ 'id' => '7', 'unitFunction' => 'członek komisji rewizyjnej' ]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('unitFunctions');
}
}

View File

@ -41,6 +41,26 @@
<input type="email" class="form-control" id="email" name="email" value="{{ old('email') }}">
</div>
<div class="form-group">
<label for="rank">Stopień:</label>
<select name="rank" class="form-control" style="width:250px">
<option value="">--- Wybierz stopień ---</option>
@foreach ($ranks as $key => $value)
<option value="{{ $key }}">{{ $value }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="unitFunction">Funkcja:</label>
<select name="unitFunction" class="form-control" style="width:250px">
<option value="0">brak funkcji</option>
@foreach ($unitFunctions as $key => $value)
<option value="{{ $key }}">{{ $value }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Submit</button>
</div>