Laravel Routing GET and POST Route parameters controller

Laravel Routing GET and POST Route parameters controller

In this Post We Will Explain About is Laravel Routing GET and POST Route parameters controller With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Simple Basic Routing using LaravelExample

READ :  wordpress INSERT Multiple Rows using $wpdb

In this post we will show you Best way to implement laravel route parameters controller, hear for php – How to route GET and POST in Laravelwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Available Router Methods

There are the following list of the Laravel Route methodes
1.Route::get($uri, $callback);
2.Route::post($uri, $callback);
3.Route::put($uri, $callback);
4.Route::patch($uri, $callback);
5.Route::delete($uri, $callback);
6.Route::options($uri, $callback);

Open routes.php file. and simple The file is located in /app/Http/
Add the simple following code to routes.php

Laravel Route GET Route

[php]
Route::get(‘/’, function()
{
//return message
return ‘welcome – infinityknow.com – Good Luck.!!’;
});
[/php]

READ :  angularbind - AngularJS Bind Function - Angular Binding Examples

Laravel Route POST Route

[php]
Route::post(‘home/admin’, function()
{
//return message
return ‘welcome – infinityknow.com – Good Luck.!!’;
});
[/php]

Laravel Route Registering A Route For Multiple Verbs

[php]
Route::match(array(‘GET’, ‘POST’), ‘/’, function()
{
//return message
return ‘welcome – infinityknow.com – Good Luck.!!’;
});
[/php]

Laravel Route Registering A Route Responding To Any HTTP Verb

[php]
Route::any(‘home’, function()
{
//return message
return ‘welcome – infinityknow.com – Good Luck.!!’;
});
[/php]

Laravel Route Forcing A Route To Be Served Over HTTPS

[php]
Route::get(‘home’, array(‘https’, function()
{
//return must be https
return ‘here simple or Must be over HTTPS’;
}));
[/php]

Laravel Route using the URL::to method:

[php]
$get_url = URL::to(‘home’);
[/php]

READ :  Vuejs RESTful Web Service Example - Vue RESTful APIs VueResource

Laravel Route : – Route Parameters

[php]
Route::get(‘product/{id}’, function($id)
{
//return id
return ‘Products ‘.$id;
});
[/php]

Laravel Route – Optional Route Parameters

[php]
Route::get(‘product/{name?}’, function($name = null)
{
//return name
return $name;
});
[/php]

Laravel Route – Optional Route Parameters With Defaults

[php]
Route::get(‘product/{name?}’, function($name = ‘laptop’)
{
//return name
return $name;
});
[/php]

Laravel Route – Regular Expression Route Constraints

[php]
Route::get(‘product/{name}’, function($name)
{
// your PHP some code here with where conditions
})
->where(‘name’, ‘[A-Za-z]+’);

Route::get(‘product/{id}’, function($id)
{
// your PHP some code here with where conditions
})
->where(‘id’, ‘[0-9]+’);
[/php]

Laravel Route – Passing An Array Of Wheres

[php]
Route::get(‘product/{id}/{name}’, function($id, $name)
{
//your PHP some code here with where
})
->where(array(‘id’ => ‘[0-9]+’, ‘name’ => ‘[a-z]+’))
[/php]

Laravel Route – Defining Global Patterns

[php]
//your pattern
Route::pattern(‘id’, ‘[0-9]+’);

//basic routings
Route::get(‘product/{id}’, function($id)
{
// your PHP some code here Like as a Only called if “{id}” is numeric.
});
[/php]

Laravel Route – Accessing A simple Route Parameter Value : use the Route::input method:

[php]
Route::filter(‘home’, function()
{
if (Route::input(‘id’) == 1)
{
// your PHP some code here
}
});
[/php]

Example

I hope you have Got What is difference between laravel get and post route And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

Leave a Reply

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