1
0
forked from s421507/eOSP2

Edycja strazak

This commit is contained in:
czup 2019-10-06 02:16:36 +02:00
commit 948337b10c
4 changed files with 107 additions and 3 deletions

View File

@ -27,7 +27,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");
}
@ -57,6 +60,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).',
@ -79,8 +84,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>