Route::model('blog', 'Blog');
Route::bind('blog', function($value, $route) {
return Blog::whereUrl($value)->first();
});
Assuming you have a Blog model the above code should do the trick.
Blog:whereUrl is simply doing a search on a column name of your choice.
You bind a parameter to a model and then in your binding you specify what column value you want to use as a parameter
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community