Dodawanie jednostki/wyswietlanie

This commit is contained in:
czup 2019-09-24 18:05:37 +02:00
parent ce1f8c65be
commit 3c86dda370
6 changed files with 70 additions and 54 deletions

View File

@ -6,54 +6,6 @@ use Illuminate\Http\Request;
use App\User;
use App\Rules\Pesel;
/*
class RegistrationController extends Controller
{
//
public function create()
{
return view('register');
}
public function store()
{
$this->validate(request(), [
'userEmail' => 'required|email',
'userLogin' => 'required',
'userPassword' => 'required',
'userName' => 'required',
'userLastName' => 'required',
'userPesel' => 'required',
'userPhone' => 'required',
]);
$request = request();
#$Uzytkownik = Uzytkownik::create(request(['userLogin', 'userPassword', 'userEmail']));
$Uzytkownik = Uzytkownik::create([
'login' => $request-> userLogin,
'password' => $request-> userPassword,
'email' => $request-> userEmail,
'name' => $request-> userName,
'surname' => $request-> userLastName,
'PESEL' => $request-> userPesel,
'phoneNumber' => $request-> userPhone,
'email' => $request-> userEmail,
'functionID' => 1,
'degreeID' => 1,
'number' => 'ABC123'
]);
auth()->login($Uzytkownik);
return redirect()->to('/jednostka');
}
}
*/
/* 'phoneNumber' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:9' */
class RegistrationController extends Controller
{

View File

@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\fireStation;
class fireStationController extends Controller
{
public function store()
{
$this->validate(request(),[
]);
$request = request();
$jednostka = fireStation::create([
'name' => $request -> name,
'number' => $request -> number,
'voivodeship' => $request -> voivodeship,
'county' => $request -> county,
'community' => $request -> community,
'postOffice' => $request -> postOffice,
'zipCode' => $request -> zipCode,
'address' => $request -> address,
'latitude' => $request -> latitude,
'longitude' => $request -> longitude,
'KRS' => $request -> KRS,
'NIP' => $request -> NIP,
'phoneNumber' => $request -> phoneNumber,
'email' => $request -> email,
'creatorID' => auth()->user()->id,
'changingID' => auth()->user()->id
]);
$user = auth()->user();
$user->fireStationID = $jednostka->id;
$user->save();
return redirect()->to('/jednostka');
}
}

View File

@ -7,8 +7,9 @@ use Illuminate\Database\Eloquent\Model;
class fireStation extends Model
{
protected $primaryKey = 'id';
protected $table = 'fireStations';
protected $fillable = [
'name', 'number', 'voivodeship', 'county', 'community', 'postOffice', 'zipCode', 'address', 'latitude', 'longtitude', 'KRS', 'NIP', 'phoneNumber', 'email', 'deleted', 'creatorID', 'changingID', 'remember_token', 'created_at', 'updated_at'
'name', 'number', 'voivodeship', 'county', 'community', 'postOffice', 'zipCode', 'address', 'latitude', 'longitude', 'KRS', 'NIP', 'phoneNumber', 'email', 'deleted', 'creatorID', 'changingID', 'remember_token', 'created_at', 'updated_at'
];
}

View File

@ -3,7 +3,7 @@
@section('center-area')
@parent
<h2>Dodaj Jednostkę</h2>
<form method="POST" action="/register">
<form method="POST" action="/jednostka">
{{ csrf_field() }}
<div class="form-group">
<label for="name">Nazwa Jednostki:</label>

View File

@ -14,10 +14,27 @@
@if( auth()->check() )
@if( auth()->user()->fireStationID == NULL)
null
@include('inc.addFireStation')
@elsegit
@php $jednostka = \App\fireStation::find(auth()->user()->fireStationID); @endphp
<div>
<p><b>Nazwa:</b> {{ $jednostka-> name }}</p>
<p><b>Województwo:</b> Wielkopolskie</p>
<p><b>Powiat:</b> Koniński</p>
<p><b>Gmina i numer ewidencyjny:</b> Skulsk 3010092</p>
<p><b>Kod pocztowy, Miejscowość:</b> 62-560 Skulsk</p>
<p><b>Ulica i numer:</b> Łuszczewo 81</p>
<p><b>Szerokość i długość geograficzna:</b> 523113.08 | 182155.88</p>
<p><b>KRS:</b> 0000003716</p>
<p><b>NIP:</b> 665 524 497 69 </p>
<p><b>Telefon:</b> ??? - ??? - ???</p>
<p><b>E-mail:</b> twojanazwa@domena.com</p>
<hr>
<p><b>Liczba członków:</b> 40</p>
</div>
<div>
@endif
@else
notnull
<div>
<p><b>Nazwa:</b> Ochotnicza Straż Pożarna w Łuszczewie</p>
<p><b>Województwo:</b> Wielkopolskie</p>
@ -35,6 +52,5 @@
</div>
<div>
@endif
@endif
</div>
@stop

View File

@ -50,6 +50,8 @@ Route::post('/login', 'SessionsController@store');
Route::get('/logout', 'SessionsController@destroy');
Route::post('/jednostka', 'fireStationController@store');
//Auth::routes();
//
//Route::get('/home', 'HomeController@index')->name('home');