Skip to content

Commit

Permalink
Merge pull request #4 from whitecube/fix-infinite-redirections
Browse files Browse the repository at this point in the history
fix infinite redirections
  • Loading branch information
toonvandenbos authored Dec 15, 2023
2 parents 3b75300 + 3897311 commit d8ae9c0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/HasSlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,12 @@ public function resolveRouteBinding($value, $field = null)
->get();

// If we have zero or multiple results, don't guess
if($results->count() !== 1) {
return;
if($results->count() === 1) {
return $results->first();
}

// Redirect to the current route using the translated model key
return abort(301, '', ['Location' => $results->first()->getSluggedUrlForRoute(
Router::current(), $locale, false
)]);
return abort(404);
}

/**
Expand Down

0 comments on commit d8ae9c0

Please sign in to comment.