Browse Source

Changing default routing setup.

Taylor Otwell 10 years ago
parent
commit
0ee0c434a3

+ 8 - 20
app/Http/Controllers/Auth/AuthController.php → app/Http/Controllers/AuthController.php

@@ -1,13 +1,9 @@
-<?php namespace App\Http\Controllers\Auth;
+<?php namespace App\Http\Controllers;
 
-use Illuminate\Routing\Controller;
 use Illuminate\Contracts\Auth\Guard;
 use App\Http\Requests\Auth\LoginRequest;
 use App\Http\Requests\Auth\RegisterRequest;
 
-/**
- * @Middleware("guest", except={"logout"})
- */
 class AuthController extends Controller {
 
 	/**
@@ -26,16 +22,16 @@ class AuthController extends Controller {
 	public function __construct(Guard $auth)
 	{
 		$this->auth = $auth;
+
+		$this->middleware('guest', ['except' => 'logout']);
 	}
 
 	/**
 	 * Show the application registration form.
 	 *
-	 * @Get("auth/register")
-	 *
 	 * @return Response
 	 */
-	public function showRegistrationForm()
+	public function getRegister()
 	{
 		return view('auth.register');
 	}
@@ -43,12 +39,10 @@ class AuthController extends Controller {
 	/**
 	 * Handle a registration request for the application.
 	 *
-	 * @Post("auth/register")
-	 *
 	 * @param  RegisterRequest  $request
 	 * @return Response
 	 */
-	public function register(RegisterRequest $request)
+	public function postRegister(RegisterRequest $request)
 	{
 		// Registration form is valid, create user...
 
@@ -60,11 +54,9 @@ class AuthController extends Controller {
 	/**
 	 * Show the application login form.
 	 *
-	 * @Get("auth/login")
-	 *
 	 * @return Response
 	 */
-	public function showLoginForm()
+	public function getLogin()
 	{
 		return view('auth.login');
 	}
@@ -72,12 +64,10 @@ class AuthController extends Controller {
 	/**
 	 * Handle a login request to the application.
 	 *
-	 * @Post("auth/login")
-	 *
 	 * @param  LoginRequest  $request
 	 * @return Response
 	 */
-	public function login(LoginRequest $request)
+	public function postLogin(LoginRequest $request)
 	{
 		if ($this->auth->attempt($request->only('email', 'password')))
 		{
@@ -92,11 +82,9 @@ class AuthController extends Controller {
 	/**
 	 * Log the user out of the application.
 	 *
-	 * @Get("auth/logout")
-	 *
 	 * @return Response
 	 */
-	public function logout()
+	public function getLogout()
 	{
 		$this->auth->logout();
 

+ 10 - 0
app/Http/Controllers/Controller.php

@@ -0,0 +1,10 @@
+<?php namespace App\Http\Controllers;
+
+use Illuminate\Routing\Controller as BaseController;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+
+abstract class Controller extends BaseController {
+
+	use ValidatesRequests;
+
+}

+ 6 - 9
app/Http/Controllers/HomeController.php

@@ -1,23 +1,20 @@
 <?php namespace App\Http\Controllers;
 
-use Illuminate\Routing\Controller;
-
 class HomeController extends Controller {
 
 	/*
 	|--------------------------------------------------------------------------
-	| Home Controller
+	| Default Home Controller
 	|--------------------------------------------------------------------------
 	|
-	| Controller methods are called when a request enters the application
-	| with their assigned URI. The URI a method responds to may be set
-	| via simple annotations. Here is an example to get you started!
+	| You may wish to use controllers instead of, or in addition to, Closure
+	| based routes. That's great! Here is an example controller method to
+	| get you started. To route to this controller, just add the route:
+	|
+	|	$router->get('/', 'HomeController@showWelcome');
 	|
 	*/
 
-	/**
-	 * @Get("/")
-	 */
 	public function index()
 	{
 		return view('hello');

+ 7 - 17
app/Http/Controllers/Auth/PasswordController.php → app/Http/Controllers/PasswordController.php

@@ -1,13 +1,9 @@
-<?php namespace App\Http\Controllers\Auth;
+<?php namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
-use Illuminate\Routing\Controller;
 use Illuminate\Contracts\Auth\PasswordBroker;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 
-/**
- * @Middleware("guest")
- */
 class PasswordController extends Controller {
 
 	/**
@@ -26,16 +22,16 @@ class PasswordController extends Controller {
 	public function __construct(PasswordBroker $passwords)
 	{
 		$this->passwords = $passwords;
+
+		$this->middleware('guest');
 	}
 
 	/**
 	 * Display the form to request a password reset link.
 	 *
-	 * @Get("password/email")
-	 *
 	 * @return Response
 	 */
-	public function showResetRequestForm()
+	public function getEmail()
 	{
 		return view('password.email');
 	}
@@ -43,12 +39,10 @@ class PasswordController extends Controller {
 	/**
 	 * Send a reset link to the given user.
 	 *
-	 * @Post("password/email")
-	 *
 	 * @param  Request  $request
 	 * @return Response
 	 */
-	public function sendResetLink(Request $request)
+	public function postEmail(Request $request)
 	{
 		switch ($response = $this->passwords->sendResetLink($request->only('email')))
 		{
@@ -63,12 +57,10 @@ class PasswordController extends Controller {
 	/**
 	 * Display the password reset view for the given token.
 	 *
-	 * @Get("password/reset/{token}")
-	 *
 	 * @param  string  $token
 	 * @return Response
 	 */
-	public function showResetForm($token = null)
+	public function getReset($token = null)
 	{
 		if (is_null($token))
 		{
@@ -81,12 +73,10 @@ class PasswordController extends Controller {
 	/**
 	 * Reset the given user's password.
 	 *
-	 * @Post("password/reset")
-	 *
 	 * @param  Request  $request
 	 * @return Response
 	 */
-	public function resetPassword(Request $request)
+	public function postReset(Request $request)
 	{
 		$credentials = $request->only(
 			'email', 'password', 'password_confirmation', 'token'

+ 30 - 0
app/Http/routes.php

@@ -0,0 +1,30 @@
+<?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');

+ 4 - 1
app/Providers/RouteServiceProvider.php

@@ -49,7 +49,10 @@ class RouteServiceProvider extends ServiceProvider {
 	 */
 	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');
+		});
 	}
 
 }