Dodawanie uzytkownikow do jednostki

This commit is contained in:
czup 2019-09-25 18:42:48 +02:00
commit 71e6ffb5da
4 changed files with 250 additions and 12 deletions

View File

@ -20,6 +20,16 @@ class fireStationController extends Controller
public function store()
{
$this->validate(request(),[
'name' => 'required|min:3|max:45',
'number' => 'required|numeric',
'postOffice' => 'required|min:3|max:45',
'zipCode' => 'required|digits:5',
'address' => 'required|min:3|max:45',
'KRS' => 'required|digits:10',
'NIP' => 'required|digits:10',
'phoneNumber' => 'required|numeric|min:9|max:11',
'email' => 'required|email|unique:firestations',
]);

View File

@ -0,0 +1,145 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class JednostkiTerytorialne extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('wojewodztwa', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
});
Schema::create('powiaty', function (Blueprint $table) {
$table->increments('id');
$table->integer('wojewodztwo_id');
$table->string('name');
});
Schema::create('gminy', function (Blueprint $table) {
$table->increments('id');
$table->integer('wojewodztwo_id');
$table->integer('powiat_id');
$table->string('name');
});
// dane testowe
DB::table('wojewodztwa')->insert(
array(
'name' => 'wielkopolskie'
)
);
DB::table('wojewodztwa')->insert(
array(
'name' => 'pomorskie'
)
);
DB::table('powiaty')->insert(
array(
'wojewodztwo_id' => '1',
'name' => 'poznański'
)
);
DB::table('powiaty')->insert(
array(
'wojewodztwo_id' => '1',
'name' => 'koniński'
)
);
DB::table('powiaty')->insert(
array(
'wojewodztwo_id' => '2',
'name' => 'kartuski'
)
);
DB::table('powiaty')->insert(
array(
'wojewodztwo_id' => '2',
'name' => 'kwidzyński'
)
);
DB::table('gminy')->insert(
array(
'wojewodztwo_id' => '1',
'powiat_id' => '1',
'name' => 'Dopiewo'
)
);
DB::table('gminy')->insert(
array(
'wojewodztwo_id' => '1',
'powiat_id' => '1',
'name' => 'Suchy Las'
)
);
DB::table('gminy')->insert(
array(
'wojewodztwo_id' => '1',
'powiat_id' => '2',
'name' => 'Skulsk'
)
);
DB::table('gminy')->insert(
array(
'wojewodztwo_id' => '1',
'powiat_id' => '2',
'name' => 'Wilczyn'
)
);
DB::table('gminy')->insert(
array(
'wojewodztwo_id' => '2',
'powiat_id' => '3',
'name' => 'Sierakowice'
)
);
DB::table('gminy')->insert(
array(
'wojewodztwo_id' => '2',
'powiat_id' => '3',
'name' => 'Chmielno'
)
);
DB::table('gminy')->insert(
array(
'wojewodztwo_id' => '2',
'powiat_id' => '4',
'name' => 'Gardeja'
)
);
DB::table('gminy')->insert(
array(
'wojewodztwo_id' => '2',
'powiat_id' => '4',
'name' => 'Sadlinki'
)
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('wojewodztwa');
Schema::dropIfExists('powiaty');
Schema::dropIfExists('gminy');
}
}

View File

@ -2,6 +2,15 @@
@section('center-area')
@parent
<head>
<title>Laravel Dependent Dropdown Tutorial With Example</title>
<link rel="stylesheet" href="{{asset('css/app.css')}}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
</head>
<h2>Dodaj Jednostkę</h2>
<form method="POST" action="/jednostka">
{{ csrf_field() }}
@ -14,22 +23,27 @@
<label for="name">Numer Jednostki:</label>
<input type="text" class="form-control" id="number" name="number" value="{{ old('number') }}">
</div>
<div class="form-group">
<label for="name">Województwo:</label>
<input type="text" class="form-control" id="voivodeship" name="voivodeship" value="{{ old('voivodeship') }}">
<label for="voivodeship">Województwo:</label>
<select name="voivodeship" class="form-control" style="width:250px">
<option value="">--- Wybierz województwo ---</option>
@foreach ($voivodeships as $key => $value)
<option value="{{ $key }}">{{ $value }}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="name">Powiat:</label>
<input type="text" class="form-control" id="county" name="county" value="{{ old('county') }}">
<label for="county">Powiat:</label>
<select name="county" class="form-control"style="width:250px">
<option>--Wybierz powiat--</option>
</select>
</div>
<div class="form-group">
<label for="name">Gmina:</label>
<input type="text" class="form-control" id="community" name="community" value="{{ old('community') }}">
<label for="community">Gmina:</label>
<select name="community" class="form-control"style="width:250px">
<option>--Wybierz gminę--</option>
</select>
</div>
<div class="form-group">
@ -48,7 +62,7 @@
</div>
<div class="form-group">
<label for="name">Szerokośc Geograficzna:</label>
<label for="name">Szerokość Geograficzna:</label>
<input type="text" class="form-control" id="latitude" name="latitude" value="{{ old('latitude') }}">
</div>
@ -77,6 +91,7 @@
<input type="email" class="form-control" id="email" name="email" value="{{ old('email') }}">
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Submit</button>
@ -84,4 +99,66 @@
@include('inc.formerrors')
</form>
<script type="text/javascript">
jQuery(document).ready(function ()
{
jQuery('select[name="voivodeship"]').on('change',function(){
var voivodeshipID = jQuery(this).val();
if(voivodeshipID)
{
jQuery.ajax({
url : 'jednostka/getcounties/' +voivodeshipID,
type : "GET",
dataType : "json",
success:function(data)
{
//console.log(data);
jQuery('select[name="county"]').empty();
jQuery('select[name="county"]').append(new Option('--Wybierz powiat--', ''));
jQuery('select[name="community"]').empty();
jQuery.each(data, function(key,value){
$('select[name="county"]').append('<option value="'+ key +'">'+ value +'</option>');
});
}
});
}
else
{
$('select[name="county"]').empty();
$('select[name="community"]').empty();
}
});
jQuery('select[name="county"]').on('change',function(){
var countyID = jQuery(this).val();
if(countyID)
{
jQuery.ajax({
url : 'jednostka/getcommunities/' +countyID,
type : "GET",
dataType : "json",
success:function(data)
{
//console.log(data);
jQuery('select[name="community"]').empty();
jQuery.each(data, function(key,value){
$('select[name="community"]').append('<option value="'+ key +'">'+ value +'</option>');
});
}
});
}
else
{
$('select[name="community"]').empty();
}
});
});
</script>
@stop

View File

@ -46,10 +46,16 @@ Route::get('/logout', 'SessionsController@destroy');
Route::get('/jednostka', 'fireStationController@create');
Route::post('/jednostka', 'fireStationController@store');
Route::get('/strazacy', 'fireFightersController@create');
Route::get('/strazacy/add', 'fireFightersController@addForm');
Route::post('/strazacy', 'fireFightersController@store');
Route::get('/jednostka','DataController@getVoivodeships');
Route::get('/jednostka/getcounties/{id}','DataController@getCounties');
Route::get('/jednostka/getcommunities/{id}','DataController@getCommunities');
//Auth::routes();
//
//Route::get('/home', 'HomeController@index')->name('home');