Laravel-adminlte.php不';无法识别身份验证::id()

Laravel-adminlte.php不';无法识别身份验证::id(),php,laravel,laravel-5,Php,Laravel,Laravel 5,我已经下载并安装了adminlte软件包,为我创建了一个管理面板模板。面板运行良好,我已经构建了很多功能,但我无法将变量发送到路由。例如: 在adminlte.php中,您构建了如下侧菜单: 该视图显示: 但是,当我在'Perfil'部分单击时,它无法识别Auth::id(),它将其视为字符串,而不是实际记录的用户id。我得到的错误是: 我尝试添加use-illumb\Support\Facades\Auth同时发送到adminlte.php和controller,但仍然不起作用 路线:

我已经下载并安装了adminlte软件包,为我创建了一个管理面板模板。面板运行良好,我已经构建了很多功能,但我无法将变量发送到路由。例如:

在adminlte.php中,您构建了如下侧菜单:

该视图显示:

但是,当我在'Perfil'部分单击时,它无法识别
Auth::id()
,它将其视为字符串,而不是实际记录的用户id。我得到的错误是:

我尝试添加
use-illumb\Support\Facades\Auth
同时发送到adminlte.php和controller,但仍然不起作用

路线:

// Middleware to check if user is Admin
  Route::group(['middleware' => 'Admin'], function() {

     Route::group(['prefix' => '/perfil'], function() {
        Route::get('/{id}', 'AdminPanelController@getProfile');
      });

   });
getProfile方法:

public function getProfile($id) {
    $user = User::findOrFail($id);
    return view("admin_panel.info_views.users.user_profile")->with("user", $user);
  }
adminlte.php:

<?php


return [

    /*
    |--------------------------------------------------------------------------
    | Title
    |--------------------------------------------------------------------------
    |
    | The default title of your admin panel, this goes into the title tag
    | of your page. You can override it per page with the title section.
    | You can optionally also specify a title prefix and/or postfix.
    |
    */

    'title' => 'AdminLTE 2',

    'title_prefix' => '',

    'title_postfix' => '',

    /*
    |--------------------------------------------------------------------------
    | Logo
    |--------------------------------------------------------------------------
    |
    | This logo is displayed at the upper left corner of your admin panel.
    | You can use basic HTML here if you want. The logo has also a mini
    | variant, used for the mini side bar. Make it 3 letters or so
    |
    */

    'logo' => '<b>UNIK</b>HB',

    'logo_mini' => '<b>U</b>NK',

    /*
    |--------------------------------------------------------------------------
    | Skin Color
    |--------------------------------------------------------------------------
    |
    | Choose a skin color for your admin panel. The available skin colors:
    | blue, black, purple, yellow, red, and green. Each skin also has a
    | ligth variant: blue-light, purple-light, purple-light, etc.
    |
    */

    'skin' => 'yellow',

    /*
    |--------------------------------------------------------------------------
    | Layout
    |--------------------------------------------------------------------------
    |
    | Choose a layout for your admin panel. The available layout options:
    | null, 'boxed', 'fixed', 'top-nav'. null is the default, top-nav
    | removes the sidebar and places your menu in the top navbar
    |
    */

    'layout' => null,

    /*
    |--------------------------------------------------------------------------
    | Collapse Sidebar
    |--------------------------------------------------------------------------
    |
    | Here we choose and option to be able to start with a collapsed side
    | bar. To adjust your sidebar layout simply set this  either true
    | this is compatible with layouts except top-nav layout option
    |
    */

    'collapse_sidebar' => false,

    /*
    |--------------------------------------------------------------------------
    | URLs
    |--------------------------------------------------------------------------
    |
    | Register here your dashboard, logout, login and register URLs. The
    | logout URL automatically sends a POST request in Laravel 5.3 or higher.
    | You can set the request to a GET or POST with logout_method.
    | Set register_url to null if you don't want a register link.
    |
    */

    'dashboard_url' => 'home',

    'logout_url' => 'logout',

    'logout_method' => null,

    'login_url' => 'login',

    'register_url' => 'register',

    /*
    |--------------------------------------------------------------------------
    | Menu Items
    |--------------------------------------------------------------------------
    |
    | Specify your menu items to display in the left sidebar. Each menu item
    | should have a text and and a URL. You can also specify an icon from
    | Font Awesome. A string instead of an array represents a header in sidebar
    | layout. The 'can' is a filter on Laravel's built in Gate functionality.
    |
    */

    'menu' => [
        'NAVEGAÇÃO PRINCIPAL',
        [
            'text' => 'Blog',
            'url'  => 'admin/blog',
            'can'  => 'manage-blog',
        ],
        [
            'text'        => 'Painel principal',
            'url'         => 'admin/painel',
            'icon'        => 'dashboard',
        ],
        [
            'text'    => 'Editar páginas',
            'icon'    => 'edit',
            'submenu' => [
                [
                    'text' => 'Vantagens',
                    'url'  => 'admin/editar_paginas/vantagens',
                    'icon_color' => 'purple',
                ],
                [
                    'text' => 'Dúvidas frequentes',
                    'url'  => "#",
                    'icon_color' => 'green',
                    'submenu' => [
                        [
                            'text' => 'Ver dúvidas/respostas',
                            'url'  => 'admin/editar_paginas/duvidas',
                            'icon_color' => 'green',
                        ],
                        [
                            'text' => 'Inserir dúvida/resposta',
                            'url'  => 'admin/editar_paginas/inserir_duvida',
                            'icon_color' => 'green',
                        ],
                    ],
                ],
                [
                    'text' => 'Equipe',
                    'url'  => "#",
                    'icon_color' => 'blue',
                    'submenu' => [
                        [
                            'text' => 'Ver equipe',
                            'url'  => 'admin/editar_paginas/equipe',
                            'icon_color' => 'blue',
                        ],
                        [
                            'text' => 'Inserir funcionário',
                            'url'  => 'admin/editar_paginas/inserir_funcionario',
                            'icon_color' => 'blue',
                        ],
                    ],
                ],
                [
                    'text'    => 'Tabela de Honorários',
                    'url'     => '#',
                    'icon_color' => 'orange',
                    'submenu' => [
                        [
                            'text' => 'Editar tabela',
                            'url'  => 'admin/editar_paginas/editar_tabela_honorarios',
                            'icon_color' => 'orange',
                        ],
                        [
                            'text' => 'Editar texto da tabela',
                            'url'  => 'admin/editar_paginas/editar_texto_tabela_honorarios',
                            'icon_color' => 'orange',
                        ],
                        [
                            'text' => 'Inserir honorários',
                            'url'  => 'admin/editar_paginas/inserir_honorario',
                            'icon_color' => 'orange',
                        ],
                    ],
                ],
                [
                    'text' => 'Level One',
                    'url'  => '#',
                ],
            ],
        ],
        'CONFIGURAÇÕES DA CONTA',
        [
            'text' => 'Perfil',
            'url' => 'admin/perfil'.\Auth::user()->id,
            'icon' => 'user',
        ],
        [
            'text' => 'Alterar senha',
            'url'  => 'admin/settings',
            'icon' => 'lock',
        ],
        'LABELS',
        [
            'text'       => 'Important',
            'icon_color' => 'red',
        ],
        [
            'text'       => 'Warning',
            'icon_color' => 'yellow',
        ],
        [
            'text'       => 'Information',
            'icon_color' => 'aqua',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Menu Filters
    |--------------------------------------------------------------------------
    |
    | Choose what filters you want to include for rendering the menu.
    | You can add your own filters to this array after you've created them.
    | You can comment out the GateFilter if you don't want to use Laravel's
    | built in Gate functionality
    |
    */

    'filters' => [
        JeroenNoten\LaravelAdminLte\Menu\Filters\HrefFilter::class,
        JeroenNoten\LaravelAdminLte\Menu\Filters\ActiveFilter::class,
        JeroenNoten\LaravelAdminLte\Menu\Filters\SubmenuFilter::class,
        JeroenNoten\LaravelAdminLte\Menu\Filters\ClassesFilter::class,
        JeroenNoten\LaravelAdminLte\Menu\Filters\GateFilter::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Plugins Initialization
    |--------------------------------------------------------------------------
    |
    | Choose which JavaScript plugins should be included. At this moment,
    | only DataTables is supported as a plugin. Set the value to true
    | to include the JavaScript file from a CDN via a script tag.
    |
    */

    'plugins' => [
        'datatables' => true,
    ],
];

因为它在引号中。将其更改为:

'url' => 'admin/perfil'.\Auth::user()->id

解决方案不是通过URL传递id,而是更改控制器方法

发件人:

公共函数getProfile($id){
$user=user::findOrFail($id);
返回视图(“admin_panel.info_views.users.user_profile”)->带有(“user”,$user);
}

致:

公共函数getProfile(){
$user=Auth::user();
返回视图(“admin_panel.info_views.users.user_profile”)->带有(“user”,$user);
}


还将路由更改为不接收参数。通过这种方式,我可以访问用户信息,而不需要通过URL传递他们的id,而URL正是我遇到问题的地方。

这样做了,由于某种原因,它破坏了整个应用程序lol无法访问任何页面(最后放上“,”。给出:@Diego你能打开调试并粘贴完整的异常吗?它打开了!只有当我执行这段代码时,它才不会显示任何内容。我不知道为什么。My.env的APP_DEBUG=true。这很奇怪。你能发布该数组的完整spinet吗?我找到了一个解决方法,而不是通过控制器中的URL传递ID,我只是做:
public function getProfile(){return view(“admin_panel.info_views.users.user_profile”)->with(“user”,Auth::user());}
它具有相同的结果,但只在路由中不显示身份验证id。我想这很好去。。。