【问题标题】:laravel : return view not return from based routelaravel:返回视图不从基于路径返回
【发布时间】:2015-11-04 00:19:27
【问题描述】:

我在 Laravel 路由中遇到问题。我可以独立走以下路线:

localhost/project/public/profile/profileSetup
localhost/project/public/thread/AddTrade

但是,如果我在路线 localhost/project/public/thread/AddTrade 上并且如果我单击配置文件设置页面链接,我将被重定向到 localhost/project/public/thread/profile/profileSetup 路径而不是 localhost/project/public/profile/profileSetup

在我的控制器中:

return view('profile.profileSetup')->with('data',$userProfile);

在我的路线中:

Route::get('profile/profileSetup', array('uses'=>'ProfileController@ProfileSetup'));

【问题讨论】:

    标签: php laravel routes


    【解决方案1】:

    始终使用命名路由进行重定向。

    这样定义路线:

     Route::get('profile/profileSetup', array('uses' => 'ProfileController@ProfileSetup','as'=>'myroute'));
    

    在你看来:

    <a href="{{{ URL::route('myroute') }}}"></a>
    

    这将相应地设置 href 属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-12
      • 2020-06-07
      • 2019-05-21
      • 1970-01-01
      • 2016-05-16
      • 2023-03-28
      • 1970-01-01
      相关资源
      最近更新 更多