Nasrul Hazim Bin Mohamad

Laravel: Route Macro

Dec
30

Here I want to show, how to extend existing route – get, post, etc. for your application.

I’m going to create a new route Route::setting('module'), which will create all necessary route setup.

Now register this new macro in your AppServiceProvider, in register() method.

Then, you can start use the new route.

To use this new route, you need a controller.

So run php artisan make:controller Settings/ApplicationSettingController -r

Then you may add in routes/web.php to register a new route setting.

In this case, you just need to add Route::setting('application').

Then run php artisan route:list. You should get something like the following:

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

5 × 2 =