laravel 5.3自訂登陸成功後的跳轉路由無效?
某草草
某草草 2017-05-16 16:48:42
0
1
598

https://laravel.com/docs/5.3/...

在官方文件中說

If the redirect path needs custom generation logic you may define a redirectTo method instead of a redirectTo property:

下面是我LoginController中的程式碼:

<?php

namespace App\Http\Controllers\User\Ui\Auth;

use App\Http\Controllers\Controller as Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Redirect;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
//    protected $redirectTo = '/';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);
        config(['app.name' => '点跃']);
    }

    public function index()
    {
        return \Auth::user();
    }

    protected function redirectTo()
    {
        die('ok');
        return Redirect::route('index');
    }
}

但是登入成功收任然跳到/home

###
某草草
某草草

全部回覆(1)
曾经蜡笔没有小新

定義一下屬性redirectTo就可以了

class LoginController extends Controller
{
    protected $redirectTo = '/index';
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板