2018-12-11 21:35
浏览 57

Laravel 5.7使用Laratrust登录,路由失败,错误路由到“/ home”

I wanted to give laratrust a shot, but I ran into some trouble with the routing. Let me explain in brief, what I did so far. I've created a new laravel app as described in the laravel docs. Then I used the make:auth generator to generate everything needed for standard login/registration. That works great. Now I am on a point, where laratrust kicks in. After installation I did everything as described in the laratrust docs. Additionally I went with DevMarketer's "Build an advanced blog" series on youtube, to get laratrust to work. The problem is now, that a login (i.e. as admin) leads me to https://myapp.local/public/home instead to https://myapp.local/public/admin/dashboard as defined so in the controller. If I edit the url after login to reach the dashboard, it works well and the dash appears. Why not after my login attempt?! Any ideas are welcome. The urls above are just examples. So don't be confused while have a look into my "AdminController":

namespace App\Http\Controllers;
use App\User;
use app\Role;
use Illuminate\Http\Request;

class AdminController extends Controller
    public function index()
        return redirect()->route('administration.dashboard');

    public function dashboard()
        return view('backend.dashboard');

My routes:

    Route::get('/', function () {
        return view('welcome');


     * Admin routes
    Route::prefix('administration')->middleware('role:superadministrator|administrator')->group(function () {
        Route::get('/', 'AdminController@index');
        Route::get('/dashboard', [
            'uses' => 'AdminController@dashboard',
            'as' => 'administration.dashboard',

So, maybe its too late for me and I won't see my mistake. Can anybody help me out? Thanks guys. Good night.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douer9399
    douer9399 2018-12-11 21:59

    Sorry guys,

    I found the answer myself. I just saw, that I forgot to customize the LoginController.

    点赞 评论