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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀