route view laravel code example

Example 1: laravel group routes

Route::group(['prefix' => 'admin'], function () {
    Route::get('users', function ()    {
        // Matches The "/admin/users" URL
    });
});

Example 2: laravel routes return view in web.php

Route::get("/page", function(){
   return View::make("dir.page");
});

Example 3: set route name laravel

Route::get('/novanoticia', 'HomeController@getNovaNoticia')->name('route_name');
Route::get('/novanoticia', ['as' => 'route_name', 'uses' => 'HomeController@getNovaNoticia']);

Example 4: laravel route pattern

Route::pattern('id', '[0-9]+');
Route::get('user/{id}', function ($id) {
    // Only executed if {id} is numeric...
});

Example 5: laravel route

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

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

Example 6: set route name laravel

Route::get('/novanoticia', 'HomeController@getNovaNoticia')->name('route_name');