laravel route implicit binding

Solutions on MaxInterview for laravel route implicit binding by the best coders in the world

showing results for - "laravel route implicit binding"
Matteo
08 Sep 2020
1// In RouteServiceProvider
2 public function boot()
3    {
4   		//don't forget import model at the top
5        Route::model('unique_key', Blog::class);
6        Route::bind('unique_key', function ($value) {
7            return Blog::findOrFail($value);
8           //return Blog::where('something', $value)->firstOrFail();
9        });
10   
11   //default laravel codes
12 }
Hyacinth
25 Nov 2019
1Route::get('api/users/{user}', function (App\User $user) {
2    return $user->email;
3});