is('back/*') || request()->is('back') || request()->routeIs('back.*')) { return Product::withTrashed() ->where('id', $value) ->orWhere('slug', $value) ->firstOrFail(); } return $this->resolveProduct($value); }); Route::bind('recipe', function (string $value) { if (request()->is('back/*') || request()->is('back') || request()->routeIs('back.*')) { return Recipe::withTrashed() ->where('id', $value) ->orWhere('slug', $value) ->firstOrFail(); } return $this->resolveRecipe($value); }); } private function resolveProduct(string $value): DomainProduct { $productDirectory = app(ProductDirectory::class); if (Str::isUuid($value) && UuidHelper::isV7(Uuid::fromString($value))) { $product = $productDirectory->find(new ProductId(Uuid::fromString($value))); } if (! isset($product)) { $product = $productDirectory->findBySlug($value); } if (! isset($product)) { throw new ModelNotFoundException('Product not found'); } return $product; } private function resolveRecipe(string $value): DomainRecipe { $recipeDirectory = app(RecipeDirectory::class); if (Str::isUuid($value) && UuidHelper::isV7(Uuid::fromString($value))) { $recipe = $recipeDirectory->find(new RecipeId(Uuid::fromString($value))); } if (! isset($recipe)) { $recipe = $recipeDirectory->findBySlug($value); } if (! isset($recipe)) { throw new ModelNotFoundException('Recipe not found'); } return $recipe; } }