Created
August 5, 2019 14:42
-
-
Save fhulufhelo/f43827ddb50b76fa46ab092e2baf28dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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