Nesting Laravel 4 Routes

Posted: 2014-01-31 13:21:00

Make sure your route file is set to show this

For my example is is projects and they have issues

So my route looks like this

#routes.php
Route::resource('projects', 'ProjectsController');
Route::resource('projects.issues', 'IssuesController');

So now my URLs will look lik this

/projects/4/issues <--shows all issues

/projects/4/issues/2 <--shows issue 2 in project 4

Finally on the Project Show page I have these linkRoute's in place

                <tr>
                    @endif
                    <td>{{ $issue['id'] }}</td>
                    <td>{{ HTML::linkRoute('projects.issues.show', $issue['name'], array($project->id, $issue['id'])) }}</td>
                    <td>{{ $issue['active'] }}</td>
                    <td>{{ $issue['description'] }}</td>
                </tr>

and

{{ HTML::linkRoute('projects.issues.create', 'Create Issue', $project->id, array('class' => 'btn btn-info')) }}

That is it. I will post my Controller shortly for Issues.

More help

https://tutsplus.com/lesson/nested-resources/


Tags:

laravel