Skip to content

Instantly share code, notes, and snippets.

@fhulufhelo
Last active August 5, 2019 13:38
Show Gist options
  • Save fhulufhelo/1ce5963041bb1d0162a91a89f956ea1b to your computer and use it in GitHub Desktop.
Save fhulufhelo/1ce5963041bb1d0162a91a89f956ea1b to your computer and use it in GitHub Desktop.
<?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