--- tags: Laravel --- # 路由常見架構 ### 常見的路由寫法 ```php= Route::get('/', function () { return view('welcome'); }); ``` ```php= Route::post('/', 'PodeController@Create'); ``` ```php= // CRUD Route::resource('user', 'UserControllerlass'); ``` ### group 群組 ```php= //group 第一個參數是陣列 "key" Route::group([ "meddleware" => 'checkClick'], function () { Route::get('/', 'PodeController@Create'); Route::post('/', 'PodeController@Create'); }); ``` ### prefix 前墬詞 * 為你路由前制定你的前墜名詞 例如 : "web" ```php= Route::group( ["meddleware" => 'chankClick', "prefix" => 'web' "namespace" => 'web' ], function () { Route::get('/', 'PodeController@Create'); Route::post('/', 'PodeController@Create'); } ); ``` ![](https://i.imgur.com/TViEo98.png) * 當後端路由 resource 產生這個bug時解的法 ![](https://i.imgur.com/lpaG3jI.png) * 可在這資料匣中設定 ![](https://i.imgur.com/LHOeQHs.png) * HOME 下方加上這段 ```php= protected $namespace = 'App\Http\Controllers'; ``` * 路由產生了 CRUD