2015-03-12 01:44:39 +01:00
|
|
|
<?php namespace App\Services;
|
|
|
|
|
2015-03-26 15:35:57 +01:00
|
|
|
use App\Model\User;
|
2015-03-12 01:44:39 +01:00
|
|
|
use Validator;
|
|
|
|
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
|
|
|
|
|
|
|
|
class Registrar implements RegistrarContract {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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, [
|
|
|
|
'name' => 'required|max:255',
|
|
|
|
'email' => 'required|email|max:255|unique:users',
|
|
|
|
'password' => 'required|confirmed|min:6',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new user instance after a valid registration.
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
* @return User
|
|
|
|
*/
|
|
|
|
public function create(array $data)
|
|
|
|
{
|
|
|
|
return User::create([
|
|
|
|
'name' => $data['name'],
|
|
|
|
'email' => $data['email'],
|
|
|
|
'password' => bcrypt($data['password']),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|