@tykus
Sorry, my English/terminology is probably off!
With source I meant the pages that exist for the dynamic route. For a database, for example a url column with 10 entries, and the dynamic route points to those 10 routes. Or for file based approach, where the controller checks if a view exists for the given variables.
So for example, a dynamic route where the closure/controller checks if a view for the request exists:
Route::get('/articles/{category}', function ($category)
{
$viewPath = "articles.{$category}";
if (!view()->exists($viewPath)) {
abort(404);
}
return view($viewPath, compact('category'));
});
I don't know if this is a standard approach, but I want a single source of truth for large sections of pages. For example, imagine we have 10 categories and 20 subcategories each. Defining a single route per page would be messy, and you would have to make sure the routes and views are always in sync.
EDIT:
For reference, here's what I mean with a database based route approach:
public function handle($url)
{
$post = Posts::where('url', $url)->first();
if (!$post) {
abort(404, 'Post not found');
}
return view('posts', [
'content' => $post->content,
...
]);
}