未定义的变量:用户(查看:C:\ xampp \ .... \ sidebar.blade.php)

时间:2019-05-26 08:26:42

标签: laravel-5.8

我要在没有resource的情况下进行编辑。

我已在边栏中进行编辑。当我单击“编辑”时,出现此错误。

  

未定义变量:用户(视图:C:\ xampp \ htdocs \ new \ shopping \ resources \ views \ Home \ panel \ sidebar.blade.php)(视图:C:\ xampp \ htdocs \ new \ shopping \ resources \ views \ Home \ panel \ sidebar.blade.php)

看看可能的代码...

web.php

Route::group(['middleware' => 'auth', 'prefix' => 'user/panel'], function () {
    Route::get('/', 'UserController@index')->name('user.panel');
    Route::get('{user}/edit', 'UserController@edit')->name('user.panel.edit');
    Route::get('/update', 'UserController@update')->name('user.panel.update');
});

UserController

public function edit(User $user)
{
    return view('Home.panel.edit', compact('user'));
}

sidebar.blade.php

<div class="col-md-2 h-100 bg-dark">
    <img src="/images/users/unknown-user.png" class="mt-5 img-fluid">
    <div class="list-group">
        <a href="{{ route('user.panel') }}" class="list-group-item list-group-item-action list-group-item-dark">
            See
        </a>
        <a href="{{ route('user.panel.edit', $user) }}" class="list-group-item list-group-item-action list-group-item-dark">
            Edit
        </a>
        <a href="#" id="logout-button" class="list-group-item list-group-item-action list-group-item-dark">
            Logout
            <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
                @csrf
            </form>
        </a>
    </div>
</div>

0 个答案:

没有答案