laravel 8 getRouteKeyName code example

Example 1: laravel group routes

Route::group(['prefix' => 'admin'], function () {
    Route::get('users', function ()    {
        // Matches The "/admin/users" URL
    });
});

Example 2: explicit route model binding in laravel

// In RouteServiceProvider
 public function boot()
    {
   		//don't forget import model at the top
        Route::model('unique_key', Blog::class);
        Route::bind('unique_key', function ($value) {
            return Blog::findOrFail($value);
           //return Blog::where('something', $value)->firstOrFail();
        });
   
   //default laravel codes
 }