Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我们如何编辑Laravel身份验证重定向url?_Php_Laravel_Laravel 5 - Fatal编程技术网

Php 我们如何编辑Laravel身份验证重定向url?

Php 我们如何编辑Laravel身份验证重定向url?,php,laravel,laravel-5,Php,Laravel,Laravel 5,在我的项目中,经过身份验证后,仪表板URL需要看起来像“” 但现在验证后显示的URL为“” 请帮我编辑网址就像 马丁:我需要从数据库中取这个名字 AuthController.php protected $redirectPath = '/dashboard'; Route::group(['middleware' => 'auth'], function () { Route::get('/dashboard', 'PublishprofileController@in

在我的项目中,经过身份验证后,仪表板URL需要看起来像“”

但现在验证后显示的URL为“”

请帮我编辑网址就像

马丁:我需要从数据库中取这个名字

AuthController.php

protected $redirectPath = '/dashboard';
    Route::group(['middleware' => 'auth'], function () {
    Route::get('/dashboard', 'PublishprofileController@index');
});
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);
    }
routes.php

protected $redirectPath = '/dashboard';
    Route::group(['middleware' => 'auth'], function () {
    Route::get('/dashboard', 'PublishprofileController@index');
});
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);
    }
PublishprofileController.php

protected $redirectPath = '/dashboard';
    Route::group(['middleware' => 'auth'], function () {
    Route::get('/dashboard', 'PublishprofileController@index');
});
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);
    }

因为您希望重定向路径是动态的,所以这可能非常复杂,甚至不可能实现。相反,您可以在
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中:

路由::get({name}/dashboard','PublishprofileController@show');


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

更改
$redirectPath='/chistoper.martin_555/dashboard'
,并为其创建一条路径,如
route::get('/chistoper.martin_555/dashboard','PublishprofileController@index');