As of Laravel 7, it is possible to specify a column to use instead of the default ID behavior when defining a route dynamic parameter.
Laravel example:
Route::get('api/posts/{post:slug}', function (App\Post $post) {
return $post;
});
It would be really handy to have a similar feature in Statamic. Here would be my real life application for this (multi-site setup):
// In route files
Route::statamic('/gallery/artists/{artist:slug}/creations/{slug}', 'creations.show');
Route::statamic('/fr/galerie/artistes/{artist:slug}/creations/{slug}', 'creations.show');
// In yaml collection files
route:
en: '/gallery/artists/{artist:slug}/creations/{slug}'
fr: '/galerie/artistes/{artist:slug}/creations/{slug}'
In my real life example, I can link an artist (required) to a creation via an "Entries" field type with the "artist" handle. so it would be great to be able to use the artists slug in the URL instead of its ID (as it's currently possible). I have the exact same yaml setup as above, but without the :slug, so an example of what I'm getting currently is: /gallery/artists/b84bd0ba-7ecb-48e1-ae73-3dd164e4a7fb/creations/my-creation-test.
As of Laravel 7, it is possible to specify a column to use instead of the default ID behavior when defining a route dynamic parameter.
Laravel example:
It would be really handy to have a similar feature in Statamic. Here would be my real life application for this (multi-site setup):
In my real life example, I can link an artist (required) to a creation via an "Entries" field type with the "artist" handle. so it would be great to be able to use the artists slug in the URL instead of its ID (as it's currently possible). I have the exact same yaml setup as above, but without the
:slug
, so an example of what I'm getting currently is:/gallery/artists/b84bd0ba-7ecb-48e1-ae73-3dd164e4a7fb/creations/my-creation-test
.