add metod to get all pages

This commit is contained in:
Gert
2015-04-20 20:53:39 +02:00
parent cff4e225e6
commit 20e771f121

View File

@@ -331,6 +331,26 @@ class Pages
return $blueprint;
}
/**
* Get all pages
* @return Collection
*/
public function all(Page $current = null)
{
$all = new Collection();
$current = $current ?: $this->root();
if ($current->routable()) {
$all[$current->path()] = [ 'slug' => $current->slug() ];
}
foreach ($current->children() as $next) {
$all->append($this->all($next));
}
return $all;
}
/**
* Get list of route/title of all pages.
*