Last active
August 5, 2019 13:38
-
-
Save fhulufhelo/1ce5963041bb1d0162a91a89f956ea1b 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; | |
class UsersController extends Controller | |
{ | |
/** | |
* handles the registration of new users | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return \Illuminate\Http\Response | |
*/ | |
public function store(Request $request) | |
{ | |
#1 Register seller | |
if ($request->role == 'seller') { | |
$user = $this->create($request->all()); | |
} | |
#2 Register buyer | |
if ($request->role == 'buyer') { | |
$user = $this->create($request->all()); | |
} | |
#3 Register admin | |
if ($request->role == 'admin') { | |
$user = $this->create($request->all()); | |
} | |
} | |
/** | |
* Store a newly created user in database. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return \App\User | |
*/ | |
function create(array $data) | |
{ | |
return User::create($data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment