Reputation: 29
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)
Upvotes: 0
Views: 113
Reputation: 152870
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;
});
Upvotes: 1