Skip to content

Commit

Permalink
Merge pull request #20 from clevyr/dev
Browse files Browse the repository at this point in the history
Fixed url generation path order
  • Loading branch information
clevyr-anthony authored Sep 16, 2020
2 parents d358d72 + 433d719 commit 2f2b509
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/app/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,21 @@ public function getHasParentPageAttribute() : bool
*/
public function getUrlAttribute() : string
{
$string = '/';

$page = $this;

$parents = [];

array_push($parents, $page->slug);

do {
if ($page->parent()->first()) {
$string .= $page->parent()->first()->slug . '/';
array_push($parents, $page->parent()->first()->slug);
$page = $page->parent()->first();
}
} while ($page->has_parent_page);

$string .= $this->slug;
return $string;
$parents = array_reverse($parents);
return '/' . implode('/', $parents);
}

/**
Expand Down

0 comments on commit 2f2b509

Please sign in to comment.