どのアドレスにアクセスした時、どの機能を呼び出すか設定
/routes/web.php Route::get('/', function () { return view('welcome'); }); //aticlesにアクセスした時ArticleControllerのindexメソッドを呼び出し、article.listでリンクを張ることができる Route::get('/articles', 'ArticleController@index')->name('article.list'); Route::get('/article/{id}', 'ArticleController@show')->name('article.show'); //正規表現によるルートの束縛 Route::get('user/{id}', function($id) { // }) ->where('id', '[0-9]+'); Route::get('user/{id}/{name}', function($id, $name) { // }) ->where(array('id' => '[0-9]+', 'name' => '[a-z]+')) //ルートパラメータを常時束縛したい場合 Route::pattern('id', '[0-9]+'); Route::get('user/{id}', function($id) { // Only called if {id} is numeric. }); //urlで表示変更 Route::get("/archives/{category}/", function($category){ return $category . "一覧"; });