Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fhulufhelo/f43827ddb50b76fa46ab092e2baf28dd to your computer and use it in GitHub Desktop.
Save fhulufhelo/f43827ddb50b76fa46ab092e2baf28dd to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Illuminate\Support\Facades\Mail;
use App\RegisterUser\Seller;
use App\RegisterUser\Admin;
use App\RegisterUser\Buyer;
use Illuminate\Auth\Access\AuthorizationException;
class UsersController extends Controller
{
/**
* handles the registration of new users
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->getRegistrationStrategy()->handle($request);
}
function getRegistrationStrategy(Request $request)
{
if ($request->role == 'seller') {
return new Seller();
}
if ($request->role == 'buyer') {
return new Buyer();
}
if ($request->role == 'admin') {
return new Admin();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment