Support the ongoing development of Laravel.io →
Database Eloquent

By using this code I'm trying to return the post from posts table which has the same id by {post}.

Route::model('posts', 'Posts');
Route::get('post/{post}', function(Posts $post){
    return $post;
});

But It returns:

Argument 1 passed to {closure}() must be an instance of Posts, string given

What's the problem? (I'm a beginner)

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.