New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Using routes with Laravel

Andreas March 11, 2021 by Andreas

I created a Collection "Jobs" and also scaffolded the resources (index and show).

Some parts of the website are done with Laravel, some with Statamic. Now my (Blade) header has this line:

<li><a href="{{ route('jobs') }}" class="{{ Route::currentRouteName() == 'jobs' ? 'current' : '' }}">Karriere</a></li>

In order to use that (ie, for active nav class), I needed to create a custom Statamic route in my web.php:

Route::statamic('/karriere', 'jobs.index', ['layout' => 'layouts.statamic.layout'])->name('jobs');

The index view works just fine. The problem I'm now facing is that I cannot access any "Job" data in my show view. Only the slug and the global data is available when I check with {{ dump }}.

How am I able to access the actual "show" data (ie. "title", "date" etc...) in my show template? I essentially did the same thing with an "Articles" collection and that works just fine. Although, I'm not using a custom web.php route for that but let Statamic handle all routing.

Answered by Duncan McClean!
>>>>>>> Answered <<<<<<<
2 Replies