Created
February 17, 2017 22:03
-
-
Save SerafimArts/eed6f809b17fce9e1ba095898fdc3028 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 | |
/** | |
* This file is part of laravel.su package. | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ | |
declare(strict_types=1); | |
namespace App\Http\Controllers\Auth; | |
use App\Models\User; | |
use App\Http\Controllers\Controller; | |
use App\Http\Requests\RegistrationRequest; | |
use Illuminate\Contracts\Auth\StatefulGuard; | |
use Illuminate\Contracts\Auth\Guard; | |
use Illuminate\Contracts\View\Factory; | |
use Illuminate\Contracts\View\View; | |
use Illuminate\Http\RedirectResponse; | |
/** | |
* Class RegistrationController | |
* | |
* @package App\Http\Controllers\Auth | |
*/ | |
class RegistrationController extends Controller | |
{ | |
/** | |
* @param Factory $factory | |
* | |
* @return View | |
*/ | |
public function index(Factory $factory): View | |
{ | |
return $factory->make('page.auth.registration'); | |
} | |
/** | |
* @param RegistrationRequest $request | |
* @param Guard $guard | |
* | |
* @return RedirectResponse | |
*/ | |
public function register(RegistrationRequest $request, Guard $guard): RedirectResponse | |
{ | |
$user = User::create($request->only('name', 'email', 'password')); | |
/** @var StatefulGuard $guard */ | |
$guard->login($user, true); | |
return redirect()->route('home'); | |
} | |
} |
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 | |
/** | |
* This file is part of laravel.su package. | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ | |
declare(strict_types=1); | |
namespace App\Http\Controllers\Auth; | |
use App\Models\User; | |
use App\Http\Controllers\Controller; | |
use App\Http\Requests\RegistrationRequest; | |
use Illuminate\Contracts\Auth\StatefulGuard; | |
use Illuminate\Contracts\Auth\Guard; | |
use Illuminate\Contracts\View\Factory; | |
use Illuminate\Contracts\View\View; | |
use Illuminate\Http\RedirectResponse; | |
class RegistrationController extends Controller | |
{ | |
public function index(Factory $factory): View | |
{ | |
return $factory->make('page.auth.registration'); | |
} | |
public function register(RegistrationRequest $request, Guard $guard): RedirectResponse | |
{ | |
$user = User::create($request->only('name', 'email', 'password')); | |
/** @var StatefulGuard $guard */ | |
$guard->login($user, true); | |
return redirect()->route('home'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment