Support the ongoing development of Laravel.io →
posted 9 years ago
Requests
Last updated 1 year ago.
0
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

Last updated 9 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.

© 2024 Laravel.io - All rights reserved.