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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记