Laravel Routing Techniques

Laravel Routing Techniques

Before you can visit any page or post of your laravel application you will have to specifies the route for individual static page or dynamic post.

Laravel determines the way to control the the contents by assigning them to a controller.Each Controller in laravel consist of different function that controls the various data on the type of methods such as-:

GET Request => To Show Data

POST Request=>To Store The data Inside The Database

PUT Request => To Update The Data

DELETE Request=>To delete the Data

In order to Pass the requested data to the specified controller we will have to define what is called Routes

Basic Routing-:

The simplest route that can be define is:

Route::get(‘/home’,function(){

return view(‘welcome’);

});

In above route ‘/home’ is the url that appears to user something like “http://www.yourdomain.com/home”

Route::get() is defined for the GET method similarly we can define something like Route::post(),Route::put(),Route::delete() for POST, PUT and DELETE request

The Above route says that when user visits the url ” http://www.yourdomain.com/home” return the content inside the welcome.blade.php

If you want to to go to controller through route you can define something like

Route::get(‘/home’,pagecontroller@index);

where “pagecontroller” is the name of controller and “index” is the method defined inside the pagecontroller

Resource Routing

Suppose that you are working on big project which consists of hundreds of form that it might become a heavy task to define individual route for the CRUD(Create-Read-Update-Delete) functionality.

Resource routes comes in handy when you need to define the controller that handles the Crud functionality.