PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/www/auth/controllers/RegisterController.php

https://bitbucket.org/mdoviedor/hotelium
PHP | 76 lines | 35 code | 9 blank | 32 comment | 0 complexity | 1d3e71e6b4b1499a4e25c59a9d7cf49f MD5 | raw file
 1<?php
 2
 3namespace www\auth\controllers;
 4
 5use Illuminate\Foundation\Auth\RegistersUsers;
 6use Illuminate\Support\Facades\Validator;
 7use models\User;
 8use www\lib\Controller;
 9
10class RegisterController extends Controller
11{
12    /*
13    |--------------------------------------------------------------------------
14    | Register Controller
15    |--------------------------------------------------------------------------
16    |
17    | This controllers handles the registration of new users as well as their
18    | validation and creation. By default this controllers uses a trait to
19    | provide this functionality without requiring any additional code.
20    |
21    */
22
23    use RegistersUsers;
24
25    /**
26     * Where to redirect users after registration.
27     *
28     * @var string
29     */
30    protected $redirectTo = '/rooms/list';
31
32    /**
33     * Create a new controllers instance.
34     */
35    public function __construct()
36    {
37        $this->middleware('guest');
38    }
39
40    /**
41     * Get a validator for an incoming registration request.
42     *
43     * @param array $data
44     *
45     * @return \Illuminate\Contracts\Validation\Validator
46     */
47    protected function validator(array $data)
48    {
49        return Validator::make($data, [
50            'name' => 'required|string|max:255',
51            'email' => 'required|string|email|max:255|unique:users',
52            'password' => 'required|string|min:6|confirmed',
53        ]);
54    }
55
56    /**
57     * Create a new user instance after a valid registration.
58     *
59     * @param array $data
60     *
61     * @return \models\User
62     */
63    protected function create(array $data)
64    {
65        return User::create([
66            'name' => $data['name'],
67            'email' => $data['email'],
68            'password' => bcrypt($data['password']),
69        ]);
70    }
71
72    public function showRegistrationForm()
73    {
74        return view('auth::register');
75    }
76}