diff --git a/app/Http/Controllers/RegistrationController.php b/app/Http/Controllers/RegistrationController.php index d892483..1446e00 100644 --- a/app/Http/Controllers/RegistrationController.php +++ b/app/Http/Controllers/RegistrationController.php @@ -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 { diff --git a/app/Http/Controllers/fireStationController.php b/app/Http/Controllers/fireStationController.php new file mode 100644 index 0000000..646de38 --- /dev/null +++ b/app/Http/Controllers/fireStationController.php @@ -0,0 +1,45 @@ +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'); + } +} diff --git a/app/fireStation.php b/app/fireStation.php index aaf3ffa..8e3d4c7 100644 --- a/app/fireStation.php +++ b/app/fireStation.php @@ -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' ]; } diff --git a/resources/views/inc/addFireStation.blade.php b/resources/views/inc/addFireStation.blade.php index b26a803..b91e622 100644 --- a/resources/views/inc/addFireStation.blade.php +++ b/resources/views/inc/addFireStation.blade.php @@ -3,7 +3,7 @@ @section('center-area') @parent

Dodaj Jednostkę

-
+ {{ csrf_field() }}
diff --git a/resources/views/unit.blade.php b/resources/views/unit.blade.php index 872a2ee..6330202 100644 --- a/resources/views/unit.blade.php +++ b/resources/views/unit.blade.php @@ -14,12 +14,11 @@ @if( auth()->check() ) @if( auth()->user()->fireStationID == NULL) - null @include('inc.addFireStation') - @else - notnull + @elsegit + @php $jednostka = \App\fireStation::find(auth()->user()->fireStationID); @endphp
-

Nazwa: Ochotnicza Straż Pożarna w Łuszczewie

+

Nazwa: {{ $jednostka-> name }}

Województwo: Wielkopolskie

Powiat: Koniński

Gmina i numer ewidencyjny: Skulsk 3010092

@@ -35,6 +34,23 @@
@endif + @else +
+

Nazwa: Ochotnicza Straż Pożarna w Łuszczewie

+

Województwo: Wielkopolskie

+

Powiat: Koniński

+

Gmina i numer ewidencyjny: Skulsk 3010092

+

Kod pocztowy, Miejscowość: 62-560 Skulsk

+

Ulica i numer: Łuszczewo 81

+

Szerokość i długość geograficzna: 523113.08 | 182155.88

+

KRS: 0000003716

+

NIP: 665 524 497 69

+

Telefon: ??? - ??? - ???

+

E-mail: twojanazwa@domena.com

+
+

Liczba członków: 40

+
+
@endif
@stop diff --git a/routes/web.php b/routes/web.php index beeee37..efd49cd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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');