Search code examples
phproutesanchorlaravel-5.3

ErrorException in UrlGenerationException.php line 17 laravel 5.4


When i click my anchor tag i keep getting this error

Missing required parameters for [Route: voyager.users.getprofile] [URI: admin/users/{users}/{id}/getprofile]. (View: /var/www/html/testadmin/vendor/tcg/voyager/resources/views/widget.blade.php) (View: /var/www/html/testadmin/vendor/tcg/voyager/resources/views/widget.blade.php))

I have an anchor tag

<li><a href="{{ route('voyager.users.getprofile', $id) }}">Profile</a></li>

My route:

Route::group([
            'as'     => 'users.',
            'prefix' => 'users/{users}',
        ], function () use ($namespacePrefix) {

                 Route::get('{id}/getprofile', ['uses' => $namespacePrefix.'Users@getprofile', 'as' => 'getprofile']);




        });

function:

public function getprofile()
    {
        echo 'hii';exit;
    }

I don't know why this happens.any help would be appreciated.


Solution

  • Your $id's value become users's value in 'prefix' => 'users/{users}',

    Either you need to provide users value of remove it

    'prefix' => 'users/',
    

    So that $id's value goes to id parameter.