Laravel 5.2 Missing required parameters for [Route: user.profile] [URI: user/{nickname}/profile]

前端 未结 3 1603
花落未央
花落未央 2020-12-01 09:56

I keep getting this error

ErrorException in UrlGenerationException.php line 17:

When ever any page loads and I\'m logged in.

Here

相关标签:
3条回答
  • You have to pass the route parameters to the route method, for example:

    <li><a href="{{ route('user.profile', $nickname) }}">Profile</a></li>
    <li><a href="{{ route('user.settings', $nickname) }}">Settings</a></li>
    

    It's because, both routes have a {nickname} in the route declaration. I've used $nickname for example but make sure you change the $nickname to appropriate value/variable, for example, it could be something like the following:

    <li><a href="{{ route('user.settings', auth()->user()->nickname) }}">Settings</a></li>
    
    0 讨论(0)
  • 2020-12-01 10:14
    Route::group(['middleware' => 'web'], function () {
    Route::auth();
    
    Route::get('/', ['as' => 'home', 'uses' => 'BaseController@index']);
    
    Route::group(['namespace' => 'User', 'prefix' => 'user'], function(){
        Route::get('{nickname}/settings', ['as' => 'user.settings', 'uses' => 'SettingsController@index']);
        Route::get('{nickname}/profile', ['as' => 'user.profile', 'uses' => 'ProfileController@index']);
    });
    });
    
    0 讨论(0)
  • 2020-12-01 10:21

    My Solution in laravel 5.2

    {{ Form::open(['route' => ['votes.submit', $video->id],  'method' => 'POST']) }}
        <button type="submit" class="btn btn-primary">
            <span class="glyphicon glyphicon-thumbs-up"></span> Votar
        </button>
    {{ Form::close() }}
    

    My Routes File (under middleware)

    Route::post('votar/{id}', [
        'as' => 'votes.submit',
        'uses' => 'VotesController@submit'
    ]);
    
    Route::delete('votar/{id}', [
        'as' => 'votes.destroy',
        'uses' => 'VotesController@destroy'
    ]);
    
    0 讨论(0)
提交回复
热议问题