Нет описания

Registrar.php 834B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php namespace App\Services;
  2. use App\User;
  3. use Validator;
  4. use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
  5. class Registrar implements RegistrarContract {
  6. /**
  7. * Get a validator for an incoming registration request.
  8. *
  9. * @param array $data
  10. * @return \Illuminate\Contracts\Validation\Validator
  11. */
  12. public function validator(array $data)
  13. {
  14. return Validator::make($data, [
  15. 'name' => 'required|max:255',
  16. 'email' => 'required|email|max:255|unique:users',
  17. 'password' => 'required|confirmed|min:6',
  18. ]);
  19. }
  20. /**
  21. * Create a new user instance after a valid registration.
  22. *
  23. * @param array $data
  24. * @return User
  25. */
  26. public function create(array $data)
  27. {
  28. return User::create([
  29. 'name' => $data['name'],
  30. 'email' => $data['email'],
  31. 'password' => bcrypt($data['password']),
  32. ]);
  33. }
  34. }