dongpin4611 2018-12-11 21:35
浏览 74
已采纳

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":

<?php
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:

<?php
    Route::get('/', function () {
        return view('welcome');
    });

    Auth::routes();

    /**
     * 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 2018-12-11 21:59
    关注

    Sorry guys,

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 maixpy训练模型,模型训练好了以后,开发板通电会报错,不知道是什么问题
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容