This has to match up with the parent

This commit is contained in:
Lance Pioch 2024-03-20 02:19:20 -04:00
parent 7df31a1eeb
commit add838d42f

View File

@ -2,8 +2,8 @@
namespace App\Http\Middleware\Api\Client; namespace App\Http\Middleware\Api\Client;
use Illuminate\Http\Request;
use App\Models\Server; use App\Models\Server;
use Closure;
use Illuminate\Contracts\Routing\Registrar; use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Routing\Middleware\SubstituteBindings; use Illuminate\Routing\Middleware\SubstituteBindings;
@ -14,10 +14,9 @@ class SubstituteClientBindings extends SubstituteBindings
parent::__construct($router); parent::__construct($router);
} }
public function handle(Request $request, \Closure $next): mixed public function handle($request, Closure $next): mixed
{ {
// Override default behavior of the model binding to use a specific table // Override default behavior of the model binding to use a specific table column rather than the default 'id'.
// column rather than the default 'id'.
$this->router->bind('server', function ($value) { $this->router->bind('server', function ($value) {
return $this->server->query()->where(strlen($value) === 8 ? 'uuidShort' : 'uuid', $value)->firstOrFail(); return $this->server->query()->where(strlen($value) === 8 ? 'uuidShort' : 'uuid', $value)->firstOrFail();
}); });