Skip to content

Commit 0ebb3ac

Browse files
committed
Call getRouteKey() instead of accessing the key directly
1 parent cd5c2b9 commit 0ebb3ac

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/LocalizedUrlGenerator.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ protected function getLocalizedRouteKey(string $key, UrlRoutable $model, string
353353

354354
App::setLocale($locale);
355355

356-
$bindingField = $this->getBindingFieldFor($key, $model);
357-
$routeKey = $model->$bindingField;
356+
$bindingField = $this->getBindingFieldFor($key);
357+
$routeKey = $bindingField ? $model->$bindingField : $model->getRouteKey();
358358

359359
App::setLocale($originalLocale);
360360

@@ -369,12 +369,11 @@ protected function getLocalizedRouteKey(string $key, UrlRoutable $model, string
369369
* If you did not use a custom key, we'll use the default route key.
370370
*
371371
* @param string|int $key
372-
* @param \Illuminate\Contracts\Routing\UrlRoutable $model
373372
*
374373
* @return string|null
375374
*/
376-
protected function getBindingFieldFor($key, UrlRoutable $model): ?string
375+
protected function getBindingFieldFor($key): ?string
377376
{
378-
return $this->route->bindingFieldFor($key) ?: $model->getRouteKeyName();
377+
return $this->route->bindingFieldFor($key);
379378
}
380379
}

0 commit comments

Comments
 (0)