Commit 0ee0c434 authored by Taylor Otwell's avatar Taylor Otwell

Changing default routing setup.

parent aa8bf8a2
<?php namespace App\Http\Controllers\Auth; <?php namespace App\Http\Controllers;
use Illuminate\Routing\Controller;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use App\Http\Requests\Auth\LoginRequest; use App\Http\Requests\Auth\LoginRequest;
use App\Http\Requests\Auth\RegisterRequest; use App\Http\Requests\Auth\RegisterRequest;
/**
* @Middleware("guest", except={"logout"})
*/
class AuthController extends Controller { class AuthController extends Controller {
/** /**
...@@ -26,16 +22,16 @@ class AuthController extends Controller { ...@@ -26,16 +22,16 @@ class AuthController extends Controller {
public function __construct(Guard $auth) public function __construct(Guard $auth)
{ {
$this->auth = $auth; $this->auth = $auth;
$this->middleware('guest', ['except' => 'logout']);
} }
/** /**
* Show the application registration form. * Show the application registration form.
* *
* @Get("auth/register")
*
* @return Response * @return Response
*/ */
public function showRegistrationForm() public function getRegister()
{ {
return view('auth.register'); return view('auth.register');
} }
...@@ -43,12 +39,10 @@ class AuthController extends Controller { ...@@ -43,12 +39,10 @@ class AuthController extends Controller {
/** /**
* Handle a registration request for the application. * Handle a registration request for the application.
* *
* @Post("auth/register")
*
* @param RegisterRequest $request * @param RegisterRequest $request
* @return Response * @return Response
*/ */
public function register(RegisterRequest $request) public function postRegister(RegisterRequest $request)
{ {
// Registration form is valid, create user... // Registration form is valid, create user...
...@@ -60,11 +54,9 @@ class AuthController extends Controller { ...@@ -60,11 +54,9 @@ class AuthController extends Controller {
/** /**
* Show the application login form. * Show the application login form.
* *
* @Get("auth/login")
*
* @return Response * @return Response
*/ */
public function showLoginForm() public function getLogin()
{ {
return view('auth.login'); return view('auth.login');
} }
...@@ -72,12 +64,10 @@ class AuthController extends Controller { ...@@ -72,12 +64,10 @@ class AuthController extends Controller {
/** /**
* Handle a login request to the application. * Handle a login request to the application.
* *
* @Post("auth/login")
*
* @param LoginRequest $request * @param LoginRequest $request
* @return Response * @return Response
*/ */
public function login(LoginRequest $request) public function postLogin(LoginRequest $request)
{ {
if ($this->auth->attempt($request->only('email', 'password'))) if ($this->auth->attempt($request->only('email', 'password')))
{ {
...@@ -92,11 +82,9 @@ class AuthController extends Controller { ...@@ -92,11 +82,9 @@ class AuthController extends Controller {
/** /**
* Log the user out of the application. * Log the user out of the application.
* *
* @Get("auth/logout")
*
* @return Response * @return Response
*/ */
public function logout() public function getLogout()
{ {
$this->auth->logout(); $this->auth->logout();
......
<?php namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
abstract class Controller extends BaseController {
use ValidatesRequests;
}
<?php namespace App\Http\Controllers; <?php namespace App\Http\Controllers;
use Illuminate\Routing\Controller;
class HomeController extends Controller { class HomeController extends Controller {
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Home Controller | Default Home Controller
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Controller methods are called when a request enters the application | You may wish to use controllers instead of, or in addition to, Closure
| with their assigned URI. The URI a method responds to may be set | based routes. That's great! Here is an example controller method to
| via simple annotations. Here is an example to get you started! | get you started. To route to this controller, just add the route:
|
| $router->get('/', 'HomeController@showWelcome');
| |
*/ */
/**
* @Get("/")
*/
public function index() public function index()
{ {
return view('hello'); return view('hello');
......
<?php namespace App\Http\Controllers\Auth; <?php namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Contracts\Auth\PasswordBroker; use Illuminate\Contracts\Auth\PasswordBroker;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* @Middleware("guest")
*/
class PasswordController extends Controller { class PasswordController extends Controller {
/** /**
...@@ -26,16 +22,16 @@ class PasswordController extends Controller { ...@@ -26,16 +22,16 @@ class PasswordController extends Controller {
public function __construct(PasswordBroker $passwords) public function __construct(PasswordBroker $passwords)
{ {
$this->passwords = $passwords; $this->passwords = $passwords;
$this->middleware('guest');
} }
/** /**
* Display the form to request a password reset link. * Display the form to request a password reset link.
* *
* @Get("password/email")
*
* @return Response * @return Response
*/ */
public function showResetRequestForm() public function getEmail()
{ {
return view('password.email'); return view('password.email');
} }
...@@ -43,12 +39,10 @@ class PasswordController extends Controller { ...@@ -43,12 +39,10 @@ class PasswordController extends Controller {
/** /**
* Send a reset link to the given user. * Send a reset link to the given user.
* *
* @Post("password/email")
*
* @param Request $request * @param Request $request
* @return Response * @return Response
*/ */
public function sendResetLink(Request $request) public function postEmail(Request $request)
{ {
switch ($response = $this->passwords->sendResetLink($request->only('email'))) switch ($response = $this->passwords->sendResetLink($request->only('email')))
{ {
...@@ -63,12 +57,10 @@ class PasswordController extends Controller { ...@@ -63,12 +57,10 @@ class PasswordController extends Controller {
/** /**
* Display the password reset view for the given token. * Display the password reset view for the given token.
* *
* @Get("password/reset/{token}")
*
* @param string $token * @param string $token
* @return Response * @return Response
*/ */
public function showResetForm($token = null) public function getReset($token = null)
{ {
if (is_null($token)) if (is_null($token))
{ {
...@@ -81,12 +73,10 @@ class PasswordController extends Controller { ...@@ -81,12 +73,10 @@ class PasswordController extends Controller {
/** /**
* Reset the given user's password. * Reset the given user's password.
* *
* @Post("password/reset")
*
* @param Request $request * @param Request $request
* @return Response * @return Response
*/ */
public function resetPassword(Request $request) public function postReset(Request $request)
{ {
$credentials = $request->only( $credentials = $request->only(
'email', 'password', 'password_confirmation', 'token' 'email', 'password', 'password_confirmation', 'token'
......
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
$router->get('/', 'HomeController@index');
/*
|--------------------------------------------------------------------------
| Authentication & Password Reset Controllers
|--------------------------------------------------------------------------
|
| These two controllers handle the authentication of the users of your
| application, as well as the functions necessary for resetting the
| passwords for your users. You may modify or remove these files
| if you wish. They just give you a convenient starting point.
|
*/
$router->controller('auth', 'AuthController');
$router->controller('password', 'PasswordController');
...@@ -49,7 +49,10 @@ class RouteServiceProvider extends ServiceProvider { ...@@ -49,7 +49,10 @@ class RouteServiceProvider extends ServiceProvider {
*/ */
public function map(Router $router) public function map(Router $router)
{ {
// require app_path('Http/routes.php'); $router->group(['namespace' => 'App\Http\Controllers'], function($router)
{
require app_path('Http/routes.php');
});
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment