如何最小化到特定控制器的路由。
Route::get('privacypolicy', 'PrivacyPolicyController@index');
Route::get('privacypolicy1', 'PrivacyPolicyController@all');
Route::get('privacypolicy/{version_no}','PrivacyPolicyController@show');
Route::get('phno/{phno},{app_type}', 'PrivacyPolicyController@check');
我正在尝试以下代码,但它不起作用。
Route::controllers([
'privacypolicy' => 'PrivacyPolicyController@index',
'privacypolicy1' =>'PrivacyPolicyController@all',
'privacypolicy/{version_no}' => 'PrivacyPolicyController@show',
'phno/{phno},{app_type}' => 'PrivacyPolicyController@check',
]);
答案 0 :(得分:0)
你可以 Route :: controller('privacypolicy','PrivacyPolicyController');
和控制器功能如下: 公共函数anyIndex(){// code}
公共功能anyShow($ version_no){// code}
答案 1 :(得分:0)
隐式控制器需要路由方法名称以HTTP动词开头。 您的情况不适用,因为路由应以相同的基URI开头
Route::controller('privacypolicy','PrivacyPolicyController');
<?php
namespace App\Http\Controllers;
class PrivacyPolicyControllerextends Controller
{
/**
* Responds to requests to GET /privacypolicy
*/
public function getIndex()
{
//
}
/**
* Responds to requests to GET /privacypolicy/show/1
*/
public function getShow($id)
{
//
}
}