Prześlij pliki do 'resources/lang/en'
walidacja formularza rejestracji
This commit is contained in:
parent
6c2710feed
commit
c8ef0585a9
60
resources/lang/en/Pesel.php
Normal file
60
resources/lang/en/Pesel.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Rules;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
|
||||||
|
class Pesel implements Rule
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new rule instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the validation rule passes.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
|
||||||
|
// za: phpedia.pl/wiki/Walidacja_numeru_PESEL
|
||||||
|
public function passes($attribute, $value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (!preg_match('/^[0-9]{11}$/',$value)) //sprawdzamy czy ciąg ma 11 cyfr
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrSteps = array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3); // tablica z odpowiednimi wagami
|
||||||
|
$intSum = 0;
|
||||||
|
for ($i = 0; $i < 10; $i++)
|
||||||
|
{
|
||||||
|
$intSum += $arrSteps[$i] * $value[$i]; //mnożymy każdy ze znaków przez wagć i sumujemy wszystko
|
||||||
|
}
|
||||||
|
$int = 10 - $intSum % 10; //obliczamy sumć kontrolną
|
||||||
|
$intControlNr = ($int == 10)?0:$int;
|
||||||
|
if ($intControlNr == $value[10]) //sprawdzamy czy taka sama suma kontrolna jest w ciągu
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation error message.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function message()
|
||||||
|
{
|
||||||
|
return 'Niepoprawny numer PESEL.';
|
||||||
|
}
|
||||||
|
}
|
109
resources/lang/en/RegistrationController.php
Normal file
109
resources/lang/en/RegistrationController.php
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
120
resources/lang/en/register.blade.php
Normal file
120
resources/lang/en/register.blade.php
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
@extends('layout.app')
|
||||||
|
|
||||||
|
|
||||||
|
@section('center-area')
|
||||||
|
@parent
|
||||||
|
|
||||||
|
|
||||||
|
{{-- <form action="/register" method="post">--}}
|
||||||
|
{{-- Użytkownik--}}
|
||||||
|
{{-- {{ csrf_field() }}--}}
|
||||||
|
{{-- <div class="form-group">--}}
|
||||||
|
{{-- <label for="title">Imię</label>--}}
|
||||||
|
{{-- <input type="text" class="form-control" id="userName" name="userName">--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
{{-- <div class="form-group">--}}
|
||||||
|
{{-- <label for="title">Nazwisko</label>--}}
|
||||||
|
{{-- <input type="text" class="form-control" id="userLastName" name="userLastName">--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
|
||||||
|
{{-- <div class="form-group">--}}
|
||||||
|
{{-- <label for="title">Pesel</label>--}}
|
||||||
|
{{-- <input type="text" class="form-control" id="userPesel" name="userPesel">--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
|
||||||
|
{{-- <div class="form-group">--}}
|
||||||
|
{{-- <label for="title">Email</label>--}}
|
||||||
|
{{-- <input type="text" class="form-control" id="userEmail" name="userEmail">--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
|
||||||
|
{{-- <label for="title">Numer telefonu</label>--}}
|
||||||
|
{{-- <input type="text" class="form-control" id="userPhone" name="userPhone">--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
|
||||||
|
{{-- <div class="form-group">--}}
|
||||||
|
{{-- <label for="title">Login</label>--}}
|
||||||
|
{{-- <input type="text" class="form-control" id="userLogin" name="userLogin">--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
|
||||||
|
{{-- <div class="form-group">--}}
|
||||||
|
{{-- <label for="title">Hasło</label>--}}
|
||||||
|
{{-- <input type="text" class="form-control" id="userPassword" name="userPassword">--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
|
||||||
|
{{-- <div class="form-group">--}}
|
||||||
|
{{-- <label for="title">Powtórz Hasło</label>--}}
|
||||||
|
{{-- <input type="text" class="form-control" id="userPassword2" name="userPassword2">--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
|
||||||
|
{{-- @if ($errors->any())--}}
|
||||||
|
{{-- <div class="alert alert-danger">--}}
|
||||||
|
{{-- <ul>--}}
|
||||||
|
{{-- @foreach ($errors->all() as $error)--}}
|
||||||
|
{{-- <li>{{ $error }}</li>--}}
|
||||||
|
{{-- @endforeach--}}
|
||||||
|
{{-- </ul>--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
{{-- @endif--}}
|
||||||
|
{{-- <button type="submit" class="btn btn-primary">Zarejestruj</button>--}}
|
||||||
|
{{-- </form>--}}
|
||||||
|
|
||||||
|
<h2>Register</h2>
|
||||||
|
<form method="POST" action="/register">
|
||||||
|
{{ csrf_field() }}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Imię:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="{{ old('name') }} ">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Nazwisko:</label>
|
||||||
|
<input type="text" class="form-control" id="surname" name="surname" value="{{ old('surname') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Login:</label>
|
||||||
|
<input type="text" class="form-control" id="login" name="login" value="{{ old('login') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Pesel:</label>
|
||||||
|
<input type="text" class="form-control" id="PESEL" name="PESEL" value="{{ old('PESEL') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Numer telefonu:</label>
|
||||||
|
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" value="{{ old('phoneNumber') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="email">Adres e-mail:</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="{{ old('email') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password">Hasło:</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password_confirmation">Powtórz hasło:</label>
|
||||||
|
<input type="password" class="form-control" id="password_confirmation" name="password_confirmation">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<button style="cursor:pointer" type="submit" class="btn btn-primary">Submit</button>
|
||||||
|
</div>
|
||||||
|
{{-- @include('partials.formerrors')--}}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@stop
|
@ -144,6 +144,15 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'attributes' => [],
|
'attributes' => [
|
||||||
|
'name' => 'imię',
|
||||||
|
'surname' => 'nazwisko',
|
||||||
|
'email' => 'adres e-mail',
|
||||||
|
'password' => 'hasło',
|
||||||
|
'PESEL' => 'numer PESEL',
|
||||||
|
'phoneNumber' => 'numer telefonu',
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user