fix: 🐛 add a condition for nullable models when laravel does not resolve them

This commit is contained in:
Alexis Gousseau 2025-07-18 16:53:46 +02:00
parent 6068573793
commit 72e16d1715
No known key found for this signature in database
GPG key ID: 4A614CB3DBBA2406

View file

@ -90,9 +90,11 @@ Breadcrumbs::for(
);
Breadcrumbs::for(
sprintf('%s.news.show', app()->currentLocale()),
function (Generator $trail, News $publishedNews) {
function (Generator $trail, News|null $publishedNews = null) {
$trail->parent(sprintf('%s.home', app()->currentLocale()));
$trail->push($publishedNews->title, route('news.show', $publishedNews));
if (!is_null($publishedNews)) {
$trail->push($publishedNews->title, route('news.show', $publishedNews));
}
}
);