Get Started. It's Free
or sign up with your email address
Laravel Routing by Mind Map: Laravel Routing

1. Route Definition

1.1. Route Verbs

1.1.1. Get

1.1.2. Post

1.1.3. Delete

1.1.4. Put

1.1.5. Any ??

1.2. Route Naming

1.2.1. should follow a convention

1.2.2. {model-name-in-plurals}.{verbs}

1.2.2.1. photos.show

1.2.2.2. photos.index

1.2.2.3. photos.edit

1.2.3. using route('name') is preferred

2. Route Groups

2.1. Middleware

2.2. Path Prefixes

2.2.1. for example : Route::group(['prefix' => 'api'], function() { Route::get('/', function(){ return 'hello world'; });

2.3. Subdomain routing

2.3.1. Route::group(['domain' => 'bne.csportal.com', function() {

2.4. Namespace prefixes

2.4.1. for shorter namespaces naming

2.5. Name prefixes

3. Views

3.1. shared variables between views

3.2. there are blade rendering system and php plain rendering system

4. Controllers

4.1. Getting User input

4.2. Injecting dependencies to Controller

4.3. Resource Controllers

4.3.1. a convention for REST/CRUD controller functions naming

4.3.2. Example: index, create, store, show, edit, update and destroy

5. Route Model Binding

5.1. Implicit Route Model Binding

5.1.1. Change the column (instead id) by getRouteKeyName

5.2. Custom Route Model Binding

5.2.1. Change the RouteServiceProvider, boot function to map with new Models

6. Form Method Spoofing

6.1. can spoof http method by adding _method input to form, and specify the intended method

7. CSRF Protection

7.1. Http method spoofing by _method={other_http_verbs}

7.2. Add <?php echo csrf_field() ?> or using with Js to add meta tags <meta name="csrf-token" content = <?php echo csrf_token(); ?>

8. Redirects & Aborting

8.1. Redirect can have shortcut [ redirect('login') === redirect()->to('login')]

8.2. use redirect()->route() to point to route name (better than redirect to ? ) we can pass the parameter too.

8.3. Other Redirect methods

8.3.1. home() : to home

8.3.2. refresh(): refresh the current page

8.3.3. away(): allows for redirecting to an external URL

8.3.4. secure() : same as to() but the parameter is set to "true"

8.3.5. action(): allows lik to a controller and methods: redirect()->action('MyController@myMethod');

8.3.6. guest(): used internally

8.3.7. intended() : use internally

8.4. redirect()->with(): redirect to different pages and pass certain data with them.

8.5. Aborting

8.5.1. abort(), abort_if() and abort_unless()

8.6. Custom Responses

8.6.1. response()->make(): first parameters is response body, second is http status code, third parameter is http headers

8.6.2. response()->json() and response()->jsonp(): return json and cross-domain allowed json

8.6.3. response()->download() and response()->file() : allows download or view file directly in browser (pdf, images ... )