# Laravel Route groups ###### tags: `Laravel` 為了讓自已設計的網站的URL跟接近RESTful,學習Larave的Route groups功能,當在看官方文件(5.7)時,只有看到 Route::prefix & Route::name … ,想要把這兩個揉在一起,雖然在其他的文件中有Route::group… 當下也沒想這麼多,就在 Laravel 讀書會發問 XD,結果第一個回覆就解了我的問題XDDD,讓自已不要忘記得記錄一下吧。 ```php <?php Route::prefix('/customer/{customer_id}', function(){ Route::get('/', 'CustomerContorller@show')->name('deaitl'); Route::prefix('/line', function(){ Route::get('/', 'LineController@index)->name('index'); Route::get('/{line_id}', 'LineController@show)->name('show'); })->name('line.'); })->name('Customer.'); ``` ```php <?php Route::group(['prefix'=>'/customer/{customer_id'}','as'=>'customer.'], function(){ Route::get('/', 'CustomerContorller@show')->name('deaitl'); Route::group(['prefix'=>'/line', 'as'=>'line.'], function(){ Route::get('/', 'LineController@index)->name('index'); Route::get('/{line_id}', 'LineController@show)->name('show'); }); }); ```