Most of the time one of the first things that we do in our controller methods is checking whether a resource exists or not and usually for that operation we rely on the Id of that Resource.

Laraval can make this much easier with it's Route Model Binding, all we have to do is make sure that the route and the controller parameter match and the controller parameter is type-hinted as the Model, then Laravel will know that the parameter we passed is an Id of the Model then so it will search for it and pass that Model instance to the controller method. If the model with the correspondent Id is not found Laravel will generate a 404 response, this is called implicit route model binding

Route::get('user/{user}', function (App\User $user) {
    return $user;
});

But sometimes we don't want to use the Id of the model to check, maybe we have a UUID and we want to make it the default column for the route model binding of that Model, In order to do that we must add the getRouteKeyName() method to the model.

public function getRouteKeyName() { 
return 'uuid';
}

Now for this model Laravel will use the UUID column when searching for the model, and if you don't want to change the default column used for that model you can just specify the column in the route like:

Route::get('user/{user:uuid}', function (App\User $user) {
    return $user;
});