1
0
forked from s421507/eOSP2
eOSP2/app/Http/Controllers/RegistrationController.php

61 lines
1.8 KiB
PHP
Raw Normal View History

2019-07-11 23:55:51 +02:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
2019-08-30 02:12:27 +02:00
use App\User;
use App\Rules\Pesel;
2019-07-11 23:55:51 +02:00
/* 'phoneNumber' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:9' */
2019-08-30 02:12:27 +02:00
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',
'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.'
2019-08-30 02:12:27 +02:00
]);
$request = request();
$user = User::create([
'password' => $request-> password,
'email' => $request-> email,
'name' => $request-> name,
'surname' => $request-> surname,
'PESEL' => $request-> PESEL,
'phoneNumber' => $request-> phoneNumber,
'functionID' => 1,
'degreeID' => 1,
'number' => 'ABC123'
]);
2019-08-30 02:12:27 +02:00
auth()->login($user);
return redirect()->to('/jednostka');
}
}