0

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)

1 Answer 1

1

The name in Route::model needs to match the parameter in your route:

Route::model('post', 'Posts'); Route::get('post/{post}', function(Posts $post){ return $post; }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.