Skip to content

Instantly share code, notes, and snippets.

@fhulufhelo
Last active August 5, 2019 15:00
Show Gist options
  • Save fhulufhelo/06730947648144300e47b25a8cd715b5 to your computer and use it in GitHub Desktop.
Save fhulufhelo/06730947648144300e47b25a8cd715b5 to your computer and use it in GitHub Desktop.
<?php
namespace App\RegisterUser;
use App\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Http\Request;
abstract class Registering
{
/**
* any inherited must create with this methods
* @return \App\User
*
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
abstract function handle(Request $request);
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function register(Request $request)
{
return $this->create($request->all());
}
/**
* Create a new user instance.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment