Dodawanie uzytkownikow do jednostki
This commit is contained in:
commit
71e6ffb5da
@ -20,6 +20,16 @@ class fireStationController extends Controller
|
|||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
$this->validate(request(),[
|
$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',
|
||||||
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
145
database/migrations/2019_09_19_113737_jednostki_terytorialne.php
Normal file
145
database/migrations/2019_09_19_113737_jednostki_terytorialne.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
@section('center-area')
|
@section('center-area')
|
||||||
@parent
|
@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>
|
<h2>Dodaj Jednostkę</h2>
|
||||||
<form method="POST" action="/jednostka">
|
<form method="POST" action="/jednostka">
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
@ -14,22 +23,27 @@
|
|||||||
<label for="name">Numer Jednostki:</label>
|
<label for="name">Numer Jednostki:</label>
|
||||||
<input type="text" class="form-control" id="number" name="number" value="{{ old('number') }}">
|
<input type="text" class="form-control" id="number" name="number" value="{{ old('number') }}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<label for="voivodeship">Województwo:</label>
|
||||||
<label for="name">Województwo:</label>
|
<select name="voivodeship" class="form-control" style="width:250px">
|
||||||
<input type="text" class="form-control" id="voivodeship" name="voivodeship" value="{{ old('voivodeship') }}">
|
<option value="">--- Wybierz województwo ---</option>
|
||||||
|
@foreach ($voivodeships as $key => $value)
|
||||||
|
<option value="{{ $key }}">{{ $value }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Powiat:</label>
|
<label for="county">Powiat:</label>
|
||||||
<input type="text" class="form-control" id="county" name="county" value="{{ old('county') }}">
|
<select name="county" class="form-control"style="width:250px">
|
||||||
|
<option>--Wybierz powiat--</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Gmina:</label>
|
<label for="community">Gmina:</label>
|
||||||
<input type="text" class="form-control" id="community" name="community" value="{{ old('community') }}">
|
<select name="community" class="form-control"style="width:250px">
|
||||||
|
<option>--Wybierz gminę--</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -48,7 +62,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<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') }}">
|
<input type="text" class="form-control" id="latitude" name="latitude" value="{{ old('latitude') }}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -77,6 +91,7 @@
|
|||||||
<input type="email" class="form-control" id="email" name="email" value="{{ old('email') }}">
|
<input type="email" class="form-control" id="email" name="email" value="{{ old('email') }}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button style="cursor:pointer" type="submit" class="btn btn-primary">Submit</button>
|
<button style="cursor:pointer" type="submit" class="btn btn-primary">Submit</button>
|
||||||
@ -84,4 +99,66 @@
|
|||||||
@include('inc.formerrors')
|
@include('inc.formerrors')
|
||||||
</form>
|
</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
|
@stop
|
||||||
|
@ -46,10 +46,16 @@ Route::get('/logout', 'SessionsController@destroy');
|
|||||||
Route::get('/jednostka', 'fireStationController@create');
|
Route::get('/jednostka', 'fireStationController@create');
|
||||||
Route::post('/jednostka', 'fireStationController@store');
|
Route::post('/jednostka', 'fireStationController@store');
|
||||||
|
|
||||||
|
|
||||||
Route::get('/strazacy', 'fireFightersController@create');
|
Route::get('/strazacy', 'fireFightersController@create');
|
||||||
Route::get('/strazacy/add', 'fireFightersController@addForm');
|
Route::get('/strazacy/add', 'fireFightersController@addForm');
|
||||||
Route::post('/strazacy', 'fireFightersController@store');
|
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();
|
//Auth::routes();
|
||||||
//
|
//
|
||||||
//Route::get('/home', 'HomeController@index')->name('home');
|
//Route::get('/home', 'HomeController@index')->name('home');
|
||||||
|
Loading…
Reference in New Issue
Block a user