Working on routing and providers.
This commit is contained in:
parent
5bb0752338
commit
d3bf13b10b
|
@ -4,19 +4,17 @@ class HomeController {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Default Home Controller
|
| Home Controller
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| You may wish to use controllers instead of, or in addition to, Closure
|
| Controller methods are called when a request enters the application
|
||||||
| based routes. That's great! Here is an example controller method to
|
| with their assigned URI. The URI a method responds to may be set
|
||||||
| get you started. To route to this controller, just add the route:
|
| via simple annotations. Here is an example to get you started!
|
||||||
|
|
|
||||||
| $router->get('/', 'HomeController@index');
|
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Get("/", as="home")
|
* @Get("/")
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?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');
|
|
|
@ -15,4 +15,13 @@ class EventServiceProvider extends ServiceProvider {
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The classes to scan for event annotations.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $scan = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,39 @@
|
||||||
<?php namespace App\Providers;
|
<?php namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Routing\Router;
|
use Illuminate\Routing\Router;
|
||||||
use Illuminate\Contracts\Routing\UrlGenerator;
|
|
||||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
class RouteServiceProvider extends ServiceProvider {
|
class RouteServiceProvider extends ServiceProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The root controller namespace for URL generation.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $rootUrlNamespace = 'App\Http\Controllers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The controllers to scan for route annotations.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $scan = [
|
||||||
|
'App\Http\Controllers\HomeController',
|
||||||
|
'App\Http\Controllers\Auth\AuthController',
|
||||||
|
'App\Http\Controllers\Auth\PasswordController',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before routes are registered.
|
* Called before routes are registered.
|
||||||
*
|
*
|
||||||
* Register any model bindings or pattern based filters.
|
* Register any model bindings or pattern based filters.
|
||||||
*
|
*
|
||||||
* @param Router $router
|
* @param Router $router
|
||||||
* @param UrlGenerator $url
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function before(Router $router, UrlGenerator $url)
|
public function before(Router $router)
|
||||||
{
|
{
|
||||||
$url->setRootControllerNamespace('App\Http\Controllers');
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,18 +41,9 @@ public function before(Router $router, UrlGenerator $url)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function map()
|
public function map(Router $router)
|
||||||
{
|
{
|
||||||
// Once the application has booted, we will include the default routes
|
//
|
||||||
// file. This "namespace" helper will load the routes file within a
|
|
||||||
// route group which automatically sets the controller namespace.
|
|
||||||
$this->app->booted(function()
|
|
||||||
{
|
|
||||||
$this->namespaced('App\Http\Controllers', function(Router $router)
|
|
||||||
{
|
|
||||||
require app_path().'/Http/routes.php';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue