Laravel Routing 2

Access Controller Methods

Route::get('/user', 'UsersController@index');

Redirection route

Route::redirect('/here', '/there', 301);

 

View route

Route::view('/welcome', 'welcome');

 

An array passed to the route

Data in the array may be passed to the view

Route::view('/welcome', 'welcome', ['name' => 'Taylor']);

Captures the URL of the user ID, it can be performed by defining the routing parameters

Route::get('user/{id}', function ($id) {

    return 'User '.$id;

});

May need to be defined according to a plurality of parameters in the route:

Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {

    //

});

 

Guess you like

Origin www.cnblogs.com/CWJDD/p/11463178.html