Skip to content

Commit

Permalink
add fallback for a renamed route
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Jun 13, 2024
1 parent 4aac835 commit febefce
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/Guidelines/Guidelines.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ public function pages(): Collection

public function page(string $slug): ?Sheet
{
return $this->pages->firstWhere('slug', $slug);
$page = $this->pages->firstWhere('slug', $slug);

if ($page) {
return $page;
}

$renamedSlug = $this->findRenamedSlugs($slug);

return $renamedSlug
? $this->pages->firstWhere('slug', $renamedSlug)
: null;
}

protected function findRenamedSlugs(string $slug): ?string
{
return match ($slug) {
'laravel-php' => 'laravel',
default => null,
};
}
}

0 comments on commit febefce

Please sign in to comment.