dpnfjx755573
2017-11-07 21:30
浏览 929
已采纳

Laravel Route资源既有GET又有POST

I have this Route

Route::group([ 'middleware' => ['auth','lang']], function() {

    // SETTINGS
    Route::namespace( 'Settings' )->prefix( 'settings' )->group( function () {

        // INDEX
        Route::get( '/', 'SettingsController@index' );

        // ACCOUNTS
        Route::resource( 'accounts', 'AccountController', ['only' => ['index','store','edit','update']] );

        // TAGS
        Route::resource( 'tags', 'TagController', ['only' => ['index','destroy']] );

        // PROFILE
        Route::get('profile', 'ProfileController@index');
        Route::post('profile', 'ProfileController@update');

    }); 

Any way I can join the two PROFILE ones into one that is resource? Whenever I try using Route::resource( 'profile', 'ProfileController', ['only' => ['index','update']] ), it gives me an error that the method is not allowed - 405 (Method Not Allowed). I think it just doesn't find the update one? I am really not sure what might be the issue.

图片转代码服务由CSDN问答提供 功能建议

我有 Route </ code> </ p>

  Route :: group(['middleware'=&gt; ['auth','lang']],function(){
 
 // SETTINGS 
 Route :: namespace('Settings') - &gt;前缀 ('settings') - &gt; group(function(){
 
 // INDEX 
 Route :: get('/','SettingsController @ index'); 
 
 // ACCOUNTS 
路由:  :资源('accounts','AccountController',['only'=&gt; ['index','store','edit','update']]); 
 
 // TAGS 
 Route ::  resource('tags','TagController',['only'=&gt; ['index','destroy']]); 
 
 // PROFILE 
 Route :: get('profile','ProfileController @  index'); 
 Route :: post('profile','ProfileController @ update'); 
 
}); 
 </ code> </ pre> 
 
 

我可以任何方式 将两个PROFILE连接到一个 resource </ code>?每当我尝试使用 Route :: resource('profile','ProfileController',['only'=&gt; ['index', 'update']])</ code>,它给我一个方法i的错误 不允许 - 405(Method Not Allowed)</ code>。 我认为它只是找不到 update </ code>一个? 我真的不确定可能是什么问题。</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题