hnhdigital-os/laravel-model-uuid

View on GitHub
example/RouteModelBindings.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace App\Http\Routes;

use App\Models\User;
use Illuminate\Routing\Router;

class RouteModelBindings
{
    /**
     * Define your route model bindings.
     *
     * @param \Illuminate\Routing\Router $router
     *
     * @return void
     */
    public static function boot(Router $router)
    {
        $router->bind('user', function ($value) {
            return User::whereUuid('uuid', $value)->first();
        });
    }
}