-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added custom registration logic to account for promoter codes
- Loading branch information
Showing
5 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Auth\Events\Registered; | ||
use Illuminate\Contracts\Auth\StatefulGuard; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Routing\Controller; | ||
use Illuminate\Support\Str; | ||
use Laravel\Fortify\Contracts\CreatesNewUsers; | ||
use Laravel\Fortify\Contracts\RegisterResponse; | ||
use Laravel\Fortify\Contracts\RegisterViewResponse; | ||
use Laravel\Fortify\Fortify; | ||
|
||
class RegisteredUserController extends Controller | ||
{ | ||
/** | ||
* The guard implementation. | ||
* | ||
* @var \Illuminate\Contracts\Auth\StatefulGuard | ||
*/ | ||
protected $guard; | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(StatefulGuard $guard) | ||
{ | ||
$this->guard = $guard; | ||
} | ||
|
||
/** | ||
* Show the registration view. | ||
*/ | ||
public function create(Request $request): RegisterViewResponse | ||
{ | ||
$promoter = null; | ||
if ($request->is('register/promoter/*')) { | ||
$promoter = $request->route('promoter'); | ||
dd($promoter); | ||
} | ||
|
||
return app(RegisterViewResponse::class); | ||
} | ||
|
||
/** | ||
* Create a new registered user. | ||
*/ | ||
public function store(Request $request, | ||
CreatesNewUsers $creator): RegisterResponse | ||
{ | ||
if (config('fortify.lowercase_usernames')) { | ||
$request->merge([ | ||
Fortify::username() => Str::lower($request->{Fortify::username()}), | ||
]); | ||
} | ||
|
||
event(new Registered($user = $creator->create($request->all()))); | ||
|
||
$this->guard->login($user); | ||
|
||
return app(RegisterResponse::class); | ||
} | ||
} |
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
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