2015-02-06 04:52:16 +01:00
|
|
|
<?php namespace FireflyIII\Services;
|
2015-02-06 04:39:52 +01:00
|
|
|
|
2015-02-06 04:52:16 +01:00
|
|
|
use FireflyIII\User;
|
2015-02-06 04:39:52 +01:00
|
|
|
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
|
2015-02-07 22:50:47 +01:00
|
|
|
use Validator;
|
2015-02-06 04:39:52 +01:00
|
|
|
|
2015-02-11 07:35:10 +01:00
|
|
|
/**
|
|
|
|
|
* Class Registrar
|
|
|
|
|
*
|
|
|
|
|
* @package FireflyIII\Services
|
|
|
|
|
*/
|
2015-02-07 22:50:47 +01:00
|
|
|
class Registrar implements RegistrarContract
|
|
|
|
|
{
|
2015-02-06 04:39:52 +01:00
|
|
|
|
2015-02-07 22:50:47 +01:00
|
|
|
/**
|
|
|
|
|
* Create a new user instance after a valid registration.
|
|
|
|
|
*
|
|
|
|
|
* @param array $data
|
|
|
|
|
*
|
|
|
|
|
* @return User
|
|
|
|
|
*/
|
|
|
|
|
public function create(array $data)
|
|
|
|
|
{
|
|
|
|
|
return User::create(
|
|
|
|
|
[
|
|
|
|
|
'email' => $data['email'],
|
|
|
|
|
'password' => bcrypt($data['password']),
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-02-06 04:39:52 +01:00
|
|
|
|
2015-02-07 22:50:47 +01:00
|
|
|
/**
|
|
|
|
|
* Get a validator for an incoming registration request.
|
|
|
|
|
*
|
|
|
|
|
* @param array $data
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\Validation\Validator
|
|
|
|
|
*/
|
|
|
|
|
public function validator(array $data)
|
|
|
|
|
{
|
|
|
|
|
return Validator::make(
|
|
|
|
|
$data, [
|
2015-02-11 07:35:10 +01:00
|
|
|
'email' => 'required|email|max:255|unique:users',
|
|
|
|
|
'password' => 'required|confirmed|min:6',
|
|
|
|
|
]
|
2015-02-07 22:50:47 +01:00
|
|
|
);
|
|
|
|
|
}
|
2015-02-06 04:39:52 +01:00
|
|
|
|
|
|
|
|
}
|