Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is Route Parameters ?



What is Route Parameters ?..

Answer / rachana devi

Sometimes in the web application, you may need to capture the parameters passed with the URL.
For this, you should modify the code in routes.php file.

You can capture the parameters in routes.php file in two ways as discussed here -

1. Required Parameters : These parameters are those which should be mandatorily captured for routing the web application.

Example : Route::get('ID/{id}',function($id)
{
echo 'ID: '.$id;
}
);

2. Optional Parameters : Sometimes developers can produce parameters as optional and it is possible with the inclusion of ? after the parameter name in URL.
It is important to keep the default value mentioned as a parameter name.

Example : Route::get('user/{name?}', function ($name = 'Manager') { return $name;});

The example above checks if the value matches to 'Manger' and accordingly routes to the defined URL.


3. Named Routes : Named routes allow a convenient way of creating routes.
The chaining of routes can be specified using name method onto the route definition.

Example : Route::get('user/profile', 'UserController@showProfile')->name('profile');

The user controller will call for the function showProfile with parameter as profile. The parameters use name method onto the route definition.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Laravel PHP Framework Interview Questions

List out the databases laravel supports?

0 Answers  


How to share your homestead with others.

0 Answers  


How to use custom table in laravel modal?

0 Answers  


How to create & register a service provider in laravel 5?

0 Answers  


Explain reverse routing in laravel.

0 Answers  


What developed the laravel?

0 Answers  


Explain how to register a service provider via composer in laravel?

0 Answers  


What is guard in laravel authentication?

0 Answers  


What do you know about php artisan? Mention some artisan command.

0 Answers  


Explain how to share your homestead with others?

0 Answers  


Differentiate between delete() and softdeletes().

0 Answers  


What do you mean by laravel dusk?

0 Answers  


Categories