From c8ef0585a99af5d9ecf88cb8caa3e081ae2cc62b Mon Sep 17 00:00:00 2001 From: Krzysztof Strzelecki Date: Tue, 17 Sep 2019 17:14:30 +0000 Subject: [PATCH 1/4] =?UTF-8?q?Prze=C5=9Blij=20pliki=20do=20'resources/lan?= =?UTF-8?q?g/en'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit walidacja formularza rejestracji --- resources/lang/en/Pesel.php | 60 ++++++++++ resources/lang/en/RegistrationController.php | 109 +++++++++++++++++ resources/lang/en/register.blade.php | 120 +++++++++++++++++++ resources/lang/en/validation.php | 11 +- 4 files changed, 299 insertions(+), 1 deletion(-) create mode 100644 resources/lang/en/Pesel.php create mode 100644 resources/lang/en/RegistrationController.php create mode 100644 resources/lang/en/register.blade.php diff --git a/resources/lang/en/Pesel.php b/resources/lang/en/Pesel.php new file mode 100644 index 0000000..937d91f --- /dev/null +++ b/resources/lang/en/Pesel.php @@ -0,0 +1,60 @@ +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 +{ + public function create() + { + return view('register'); + } + + public function store() + { + $this->validate(request(), [ + 'name' => 'required|alpha|min:3|max:45', + 'surname' => 'required|alpha|min:3|max:45', + 'login' => 'required|alpha_num|min:3|max:45', + 'PESEL' => new Pesel, + 'phoneNumber' => 'required|digits:9', + 'email' => 'required|email|unique:users', + 'password' => 'required|confirmed|min:6', + ], + [ + 'required' => ':attribute jest wymagany(e).', + 'min' => ':attribute musi mieć przynajmniej :min znaki.', + 'max' => ':attribute musi mieć nie więcej niż :max znaków.', + 'alpha' => ':attribute może zawierać tylko litery.', + 'alpha_num' => ':attribute może zawierać tylko litery i cyfry.', + 'digits' => ':attribute musi składać się z :digits cyfr.', + 'unique' =>':attribute jest już zajęty.', + 'confirmed' =>':attribute się nie zgadza.', + 'email' => 'Niepoprawny adres e-mail.' + ]); + + + $request = request(); + $user = User::create([ + 'login' => $request-> login, + 'password' => $request-> password, + 'email' => $request-> email, + 'name' => $request-> name, + 'surname' => $request-> surname, + 'PESEL' => $request-> PESEL, + 'phoneNumber' => $request-> phoneNumber, + 'functionID' => 1, + 'degreeID' => 1, + 'number' => 'ABC123' + ]); + + + auth()->login($user); + + return redirect()->to('/jednostka'); + } +} + diff --git a/resources/lang/en/register.blade.php b/resources/lang/en/register.blade.php new file mode 100644 index 0000000..e96d3a5 --- /dev/null +++ b/resources/lang/en/register.blade.php @@ -0,0 +1,120 @@ +@extends('layout.app') + + +@section('center-area') + @parent + + +{{--
--}} +{{-- Użytkownik--}} +{{-- {{ csrf_field() }}--}} +{{--
--}} +{{-- --}} +{{-- --}} +{{--
--}} +{{--
--}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{--
--}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{--
--}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{-- --}} +{{-- --}} +{{-- --}} + +{{--
--}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{--
--}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{--
--}} +{{-- --}} +{{-- --}} +{{--
--}} + +{{-- @if ($errors->any())--}} +{{--
--}} +{{--
    --}} +{{-- @foreach ($errors->all() as $error)--}} +{{--
  • {{ $error }}
  • --}} +{{-- @endforeach--}} +{{--
--}} +{{--
--}} +{{-- @endif--}} +{{-- --}} +{{--
--}} + +

Register

+
+ {{ csrf_field() }} +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + +
+ +
+{{-- @include('partials.formerrors')--}} +
+ +@stop diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 8ab929c..80713bf 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -144,6 +144,15 @@ return [ | */ - 'attributes' => [], + 'attributes' => [ + 'name' => 'imię', + 'surname' => 'nazwisko', + 'email' => 'adres e-mail', + 'password' => 'hasło', + 'PESEL' => 'numer PESEL', + 'phoneNumber' => 'numer telefonu', + ], + + ]; From 4cd4553e61ee0004c93e2c374b27506dfd77a69c Mon Sep 17 00:00:00 2001 From: Krzysztof Strzelecki Date: Tue, 17 Sep 2019 17:19:52 +0000 Subject: [PATCH 2/4] =?UTF-8?q?Prze=C5=9Blij=20pliki=20do=20'resources/vie?= =?UTF-8?q?ws'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/register.blade.php | 32 +++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/resources/views/register.blade.php b/resources/views/register.blade.php index 0353978..e96d3a5 100644 --- a/resources/views/register.blade.php +++ b/resources/views/register.blade.php @@ -27,7 +27,6 @@ {{-- --}} {{-- --}} -{{--
--}} {{-- --}} {{-- --}} {{--
--}} @@ -64,39 +63,54 @@ {{ csrf_field() }}
- +
- +
- +
- +
- +
- - + +
- +
+
+ + +
+ + @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif +
From 999d7aa317b16ab1fd90f101fbe78ca584f81d98 Mon Sep 17 00:00:00 2001 From: Krzysztof Strzelecki Date: Tue, 17 Sep 2019 17:23:43 +0000 Subject: [PATCH 3/4] =?UTF-8?q?Prze=C5=9Blij=20pliki=20do=20'app/Http/Cont?= =?UTF-8?q?rollers'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/RegistrationController.php | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/RegistrationController.php b/app/Http/Controllers/RegistrationController.php index 5996ee8..5477a0b 100644 --- a/app/Http/Controllers/RegistrationController.php +++ b/app/Http/Controllers/RegistrationController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\User; +use App\Rules\Pesel; /* @@ -53,7 +54,7 @@ class RegistrationController extends Controller } */ - +/* 'phoneNumber' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:9' */ class RegistrationController extends Controller { public function create() @@ -64,16 +65,26 @@ class RegistrationController extends Controller public function store() { $this->validate(request(), [ - 'name' => 'required', - 'surname' => 'required', - 'email' => 'required|email', - 'password' => 'required', - 'login' => 'required', - 'PESEL' => 'required', - 'phoneNumber' => 'required' - + 'name' => 'required|alpha|min:3|max:45', + 'surname' => 'required|alpha|min:3|max:45', + 'login' => 'required|alpha_num|min:3|max:45', + 'PESEL' => new Pesel, + 'phoneNumber' => 'required|digits:9', + 'email' => 'required|email|unique:users', + 'password' => 'required|confirmed|min:6', + ], + [ + 'required' => ':attribute jest wymagany(e).', + 'min' => ':attribute musi mieć przynajmniej :min znaki.', + 'max' => ':attribute musi mieć nie więcej niż :max znaków.', + 'alpha' => ':attribute może zawierać tylko litery.', + 'alpha_num' => ':attribute może zawierać tylko litery i cyfry.', + 'digits' => ':attribute musi składać się z :digits cyfr.', + 'unique' =>':attribute jest już zajęty.', + 'confirmed' =>':attribute się nie zgadza.', + 'email' => 'Niepoprawny adres e-mail.' ]); - + $request = request(); $user = User::create([ @@ -88,9 +99,11 @@ class RegistrationController extends Controller 'degreeID' => 1, 'number' => 'ABC123' ]); + auth()->login($user); return redirect()->to('/jednostka'); } } + From 9605c5e63864baab47052a3f6338067dd08b6d3e Mon Sep 17 00:00:00 2001 From: Krzysztof Strzelecki Date: Tue, 17 Sep 2019 17:28:36 +0000 Subject: [PATCH 4/4] =?UTF-8?q?Prze=C5=9Blij=20pliki=20do=20'App/Rules'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Rules/Pesel.php | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 App/Rules/Pesel.php diff --git a/App/Rules/Pesel.php b/App/Rules/Pesel.php new file mode 100644 index 0000000..937d91f --- /dev/null +++ b/App/Rules/Pesel.php @@ -0,0 +1,60 @@ +