Search code examples
routeslaravel-5.3

Laravel 5 Resource route define create URL::route('') in view


I have a href and i want to add URL::route('create') to the url like this

<a href="{{URL::route('xxx.create') }}{{$projectfornav[0]->afas_id}}"> XXX </a>

Route:

Route::resource('/xxx/{id}', 'XXXController');

Error:

Route [create.xxx] not defined. (View:......... 

But this doesn't work. How can i achieve that?


Solution

  • This is how I define a route inside a group:

    Route::group(['prefix' => 'admin', 'as' => 'admin.'], function () {
       Route::resource('user', 'userController');
    });
    

    And this is how I create the show URL for UserId 123

    URL::route('admin.user.show', 123)
    

    I think you have to change

    <a href="{{URL::route('xxx.create') }}{{$projectfornav[0]->afas_id}}"> XXX </a>
    

    to

    <a href="{{URL::route('xxx.create', $projectfornav[0]->afas_id) }}"> XXX </a>