Skip to content

Commit

Permalink
fix when there was a binded model without an accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
LeMatosDeFuk committed Dec 29, 2023
1 parent 73cfa01 commit f311aec
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Service/BreadcrumbService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use BoredProgrammers\LaraBreadcrumb\Exception\BreadcrumbException;
use BoredProgrammers\LaraBreadcrumb\Model\BreadcrumbLink;
use Closure;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -125,7 +126,11 @@ private function generateBreadcrumb($segment, $index, $parameters, &$accumulated
);
}
} else {
$segment = $this->getPrefix() ? ($this->getPrefix() . '.' . $parameterValue) : $parameterValue;
if ($parameterValue instanceof Model) {
$segment = $parameterValue->getKey();
} else {
$segment = $this->getPrefix() ? ($this->getPrefix() . '.' . $parameterValue) : $parameterValue;
}
}
} else {
$accumulatedUrl .= '/' . $segment;
Expand Down

0 comments on commit f311aec

Please sign in to comment.