tethys/app/Services/Registrar.php

41 lines
972 B
PHP
Raw Normal View History

2018-08-06 12:30:51 +00:00
<?php
namespace App\Services;
2015-07-19 06:49:24 +00:00
2018-09-10 13:09:10 +00:00
use App\Models\User;
2015-07-19 06:49:24 +00:00
use Validator;
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
2018-08-06 12:30:51 +00:00
class Registrar implements RegistrarContract
{
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00: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, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
2015-07-19 06:49:24 +00:00
2018-08-06 12:30:51 +00:00
/**
* 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']),
]);
}
2015-07-19 06:49:24 +00:00
}