Skip to content

Instantly share code, notes, and snippets.

@SerafimArts
Created February 17, 2017 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SerafimArts/eed6f809b17fce9e1ba095898fdc3028 to your computer and use it in GitHub Desktop.
Save SerafimArts/eed6f809b17fce9e1ba095898fdc3028 to your computer and use it in GitHub Desktop.
<?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');
}
}
<?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