Route::get('/', function () { return 'Hello World';});Route::post('foo/bar', function () { return 'Hello World';});Route::put('foo/bar', function () { //});Route::delete('foo/bar', function () { //
});
Route::match(['get', 'post'], '/', function () { return 'Hello World';});
Route::any('foo', function () { return 'Hello World';});
$url = url('foo');
Route::get('user/{id}', function ($id) { return 'User '.$id;});
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) { //});
Route::get('user/{name?}', function ($name = null) { return $name;});Route::get('user/{name?}', function ($name = 'John') { return $name;});
Route::get('user/{name}', function ($name) { //})->where('name', '[A-Za-z]+');Route::get('user/{id}', function ($id) { //})->where('id', '[0-9]+');Route::get('user/{id}/{name}', function ($id, $name) { //})->where(['id' => '[0-9]+', 'name' => '[a-z]+']);
Route::get('user/profile', ['as' => 'profile', function () { //}]);
Route::get('user/profile', [ 'as' => 'profile', 'uses' => 'UserController@showProfile']);
Route::get('user/profile', 'UserController@showProfile')->name('profile');
Route::group(['as' => 'admin::'], function () { Route::get('dashboard', ['as' => 'dashboard', function () { // Route named "admin::dashboard" }]);});
$url = route('profile');$redirect = redirect()->route('profile');
Route::get('user/{id}/profile', ['as' => 'profile', function ($id) { //}]);$url = route('profile', ['id' => 1]);
Route::group(['middleware' => 'auth'], function () { Route::get('/', function () { // Uses Auth Middleware }); Route::get('user/profile', function () { // Uses Auth Middleware });});
Route::group(['namespace' => 'Admin'], function(){ // Controllers Within The "App\Http\Controllers\Admin" Namespace Route::group(['namespace' => 'User'], function() { // Controllers Within The "App\Http\Controllers\Admin\User" Namespace });});
Route::group(['domain' => '{account}.myapp.com'], function () { Route::get('user/{id}', function ($account, $id) { // });});
Route::group(['prefix' => 'admin'], function () { Route::get('users', function () { // Matches The "/admin/users" URL });});
Route::group(['prefix' => 'accounts/{account_id}'], function () { Route::get('detail', function ($account_id) { // Matches The accounts/{account_id}/detail URL });});
abort(404);