Skip to content

Commit

Permalink
support translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
MoamenEltouny authored Feb 22, 2022
1 parent e22a909 commit 4118b80
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Sluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ protected static function bootSluggable()
*/
public function getSlugWithKeyAttribute()
{
$isTranslatable = substr(__CLASS__, -11) == 'Translation';
$class = substr(__CLASS__, 0, -11);

if ($isTranslatable && class_exists($class)) {
$relation = strtolower(class_basename($class));
if (method_exists($this, $relation)) {
return implode('-', [$this->{$relation}->getKey(), $this->slug]);
}
}

return implode('-', [$this->getKey(), $this->slug]);
}

Expand Down

0 comments on commit 4118b80

Please sign in to comment.