我有一些看似重复的路线。
function generateRoute($name) {
Route::get("admincp/$name", "{$name}Controller@index");
Route::post("admincp/$name/store", "{$name}Controller@store");
Route::get("admincp/$name/{id}/edit", "{$name}Controller@edit");
Route::patch("admincp/$name/{id}/update", "{$name}Controller@update");
Route::get("admincp/$name/{id}/destroy", "{$name}Controller@destroy");
}
我不想重复自己。我可以在laravel中做这样的事吗?
ave
答案 0 :(得分:1)
使用资源路线:
Route::group(['prefix' => 'admincp'], function () {
Route::resource('point', 'PointController');
Route::resource('faq', 'FaqController');
Route::resource('slider', 'SliderController');
}