michaellatham
4 months ago
555
1
Laravel

Route Model Binding in 7.x

Posted 4 months ago by michaellatham

I understand that it's now not necessary to use getRouteKeyName() in order to change the default key used, like this from the docs:

Route::get('api/posts/{post:slug}', function (App\Post $post) {
    return $post;
});

Is this syntax possible when using Route::resource(), or do I need to still use getRouteKeyName() on the model?

Please sign in or create an account to participate in this conversation.