1
0
forked from s421507/eOSP2

Jednostka czesciowo + korekta mergowania

This commit is contained in:
czup 2019-09-19 11:22:54 +02:00
commit a9ac22be16
11 changed files with 563 additions and 34 deletions

View File

@ -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,13 +65,24 @@ class RegistrationController extends Controller
public function store()
{
$this->validate(request(), [
'name' => 'required',
'surname' => 'required',
'email' => 'required|email',
'password' => 'required',
'PESEL' => 'required',
'phoneNumber' => 'required'
'name' => 'required|alpha|min:3|max:45',
'surname' => 'required|alpha|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.'
]);
@ -87,8 +99,10 @@ class RegistrationController extends Controller
'number' => 'ABC123'
]);
auth()->login($user);
return redirect()->to('/jednostka');
}
}

60
app/Rules/Pesel.php Normal file
View 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.';
}
}

14
app/fireStation.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class fireStation extends Model
{
protected $primaryKey = 'id';
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'
];
}

View File

@ -14,7 +14,7 @@ class CreatePasswordResetsTable extends Migration
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('email');
$table->string('token');
$table->timestamp('created_at')->nullable();
});

View 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.';
}
}

View 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');
}
}

View 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

View File

@ -144,6 +144,15 @@ return [
|
*/
'attributes' => [],
'attributes' => [
'name' => 'imię',
'surname' => 'nazwisko',
'email' => 'adres e-mail',
'password' => 'hasło',
'PESEL' => 'numer PESEL',
'phoneNumber' => 'numer telefonu',
],
];

View File

@ -0,0 +1,118 @@
@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">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('inc.formerrors')
</form>
@stop

View File

@ -27,7 +27,6 @@
{{-- <input type="text" class="form-control" id="userEmail" name="userEmail">--}}
{{-- </div>--}}
{{-- <div class="form-group">--}}
{{-- <label for="title">Numer telefonu</label>--}}
{{-- <input type="text" class="form-control" id="userPhone" name="userPhone">--}}
{{-- </div>--}}
@ -64,34 +63,52 @@
{{ csrf_field() }}
<div class="form-group">
<label for="name">Imię:</label>
<input type="text" class="form-control" id="name" name="name">
<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">
<input type="text" class="form-control" id="surname" name="surname" value="{{ old('surname') }}">
</div>
<div class="form-group">
<label for="name">Pesel:</label>
<input type="text" class="form-control" id="PESEL" name="PESEL">
<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">
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" value="{{ old('phoneNumber') }}">
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" name="email">
<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">Password:</label>
<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>

View File

@ -11,6 +11,13 @@
@section('center-area')
@parent
@if( auth()->check() )
@if( auth()->user()->fireStationID == NULL)
null
@else
notnull
<div>
<p><b>Nazwa:</b> Ochotnicza Straż Pożarna w Łuszczewie</p>
<p><b>Województwo:</b> Wielkopolskie</p>
@ -27,6 +34,7 @@
<p><b>Liczba członków:</b> 40</p>
</div>
<div>
@endif
@endif
</div>
@stop