2015-10-06 41 views
0

在验证仪表板URL后,我的项目需要看起来像“http://www.ct.dev/chistoper.martin_555/dashboard”。我们如何编辑Laravel Auth重定向url?

但是现在验证后的URL显示为“http://www.ct.dev/dashboard”。

请帮我编辑url,就像http://www.ct.dev/chistoper.martin_555/dashboard一样。

chistoper.martin_555:我需要从数据库中取这个名字。

AuthController.php

protected $redirectPath = '/dashboard'; 

routes.php文件

Route::group(['middleware' => 'auth'], function() { 
    Route::get('/dashboard', '[email protected]'); 
}); 

PublishprofileController.php

public function index() 
    { 
     session()->put('userID', Auth::user()->id); 
     $confirmDetails = User::select('confirmed_at') 
      ->where('id', session()->get('userID')) 
      ->first(); 
     return view('test.frontend')->with('confirmTime', $confirmDetails->confirmed_at); 
    } 
+0

改变你的'$ redirectPath ='/ chistoper.martin_555/dashboard''并为它就像'Route :: get('/ chistoper.martin_555/dashboard','PublishprofileController @ index');' –

回答

0

既然你希望你的重定向路径是动态的,这可能是非常复杂的,它甚至不可能。相反,您可以在您的PublishprofileController中执行此操作。这具有更简洁的优点,并且可以很容易地被改变。

public function index() 
{ 
    session()->put('userID', Auth::user()->id); 
    $confirmDetails = User::select('confirmed_at') 
     ->where('id', session()->get('userID')) 
     ->first(); 
    return redirect(Auth::user()->name.'/dashboard'); 
} 

然后在您的routes.php

路线::得到( '(名称)/仪表板', 'PublishprofileController @秀');

然后编辑您的show方法返回视图。显然还有更多的代码需要编写,这部分是由你自己决定的,但是这应该让你走上正确的轨道

+0

非常感谢。我知道了。 –

+0

很高兴能帮到你! – samrap