moved composers, filters and routes back to application, delete routes folder
This commit is contained in:
27
application/composers.php
Normal file
27
application/composers.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| View Composers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| View composers provide a convenient way to add common elements to a view
|
||||||
|
| each time it is created. For example, you may wish to bind a header and
|
||||||
|
| footer partial each time the view is created.
|
||||||
|
|
|
||||||
|
| The composer will receive an instance of the view being created, and is
|
||||||
|
| free to modify the view however you wish. Be sure to always return the
|
||||||
|
| view instance at the end of your composer.
|
||||||
|
|
|
||||||
|
| For more information, check out: http://laravel.com/docs/start/views#composers
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'home/index' => function($view)
|
||||||
|
{
|
||||||
|
return $view;
|
||||||
|
},
|
||||||
|
|
||||||
|
);
|
||||||
70
application/filters.php
Normal file
70
application/filters.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Filters
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Filters provide a convenient method for attaching functionality to your
|
||||||
|
| routes. Filters can run either before or after a route is exectued.
|
||||||
|
|
|
||||||
|
| The built-in "before" and "after" filters are called before and after
|
||||||
|
| every request to your application; however, you may create other filters
|
||||||
|
| that can be attached to individual routes.
|
||||||
|
|
|
||||||
|
| Filters also make common tasks such as authentication and CSRF protection
|
||||||
|
| a breeze. If a filter that runs before a route returns a response, that
|
||||||
|
| response will override the route action.
|
||||||
|
|
|
||||||
|
| Let's walk through an example...
|
||||||
|
|
|
||||||
|
| First, define a filter:
|
||||||
|
|
|
||||||
|
| 'simple_filter' => function()
|
||||||
|
| {
|
||||||
|
| return 'Filtered!';
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| Next, attach the filter to a route:
|
||||||
|
|
|
||||||
|
| 'GET /' => array('before' => 'simple_filter', 'do' => function()
|
||||||
|
| {
|
||||||
|
| return 'Hello World!';
|
||||||
|
| })
|
||||||
|
|
|
||||||
|
| Now every requests to http://example.com will return "Filtered!", since
|
||||||
|
| the filter is overriding the route action by returning a value.
|
||||||
|
|
|
||||||
|
| To make your life easier, we have built authentication and CSRF filters
|
||||||
|
| that are ready to attach to your routes. Enjoy.
|
||||||
|
|
|
||||||
|
| For more information, check out: http://laravel.com/docs/start/routes#filters
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'before' => function()
|
||||||
|
{
|
||||||
|
// Do stuff before every request is executed.
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
'after' => function($response)
|
||||||
|
{
|
||||||
|
// Do stuff after every request is executed.
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
'auth' => function()
|
||||||
|
{
|
||||||
|
return ( ! Auth::check()) ? Redirect::to_login() : null;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
'csrf' => function()
|
||||||
|
{
|
||||||
|
return (Input::get('csrf_token') !== Form::raw_token()) ? Response::error('500') : null;
|
||||||
|
},
|
||||||
|
|
||||||
|
);
|
||||||
47
application/routes.php
Normal file
47
application/routes.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is the public API of your application. To add functionality to your
|
||||||
|
| application, you just add to the array located in this file.
|
||||||
|
|
|
||||||
|
| Simply tell Laravel the HTTP verbs and request URIs it should respond to.
|
||||||
|
| You may respond to the GET, POST, PUT, or DELETE verbs. Enjoy the simplicity
|
||||||
|
| and elegance of RESTful routing.
|
||||||
|
|
|
||||||
|
| Here is how to respond to a simple GET request to http://example.com/hello:
|
||||||
|
|
|
||||||
|
| 'GET /hello' => function()
|
||||||
|
| {
|
||||||
|
| return 'Hello World!';
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| You can even respond to more than one URI:
|
||||||
|
|
|
||||||
|
| 'GET /hello, GET /world' => function()
|
||||||
|
| {
|
||||||
|
| return 'Hello World!';
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| Allow URI wildcards using the (:num) or (:any) place-holders:
|
||||||
|
|
|
||||||
|
| 'GET /hello/(:any)' => function($name)
|
||||||
|
| {
|
||||||
|
| return "Welcome, $name.";
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| Ready to learn more? Check out: http://laravel.com/docs/start/routes
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'GET /' => function()
|
||||||
|
{
|
||||||
|
return View::make('home/index');
|
||||||
|
},
|
||||||
|
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user