Provide functions to render regular pages with parent-child relationships.

1.0.0 2015-10-13 05:02 UTC

This package is auto-updated.

Last update: 2024-02-15 13:13:46 UTC


  • Find your page by alias(aboutus, service, and so on), forget about id.
  • Support page with parent-child structure.
  • Support custom view for different pages.
  • Support breadcrumb(with ancestors function).


  1. install package

    composer require unisharp/laravel-pagerender
  2. use the trait in your model

    use \Unisharp\Pagerender\PageRenderTrait;
    private $default_view = 'page.show';
  3. make sure your table has these columns : parent_id, alias, custom_view

    public function up()
        Schema::create('models', function(Blueprint $table)
            // ...
            $table->string('custom_view', 128)->nullable();
            // ..


    $page = new Page();

    // Generates the default view(or custom view if the column is not empty).

    $page->summary('content', 7);
    // Shorten words of a column, ex: The PHP...

    // Get the about us page.

    // Check if the about us page exists.

    // Get pages that have alias.

    // Get children pages.

    // Check if children pages exist.

    // Get parent page.

    // Check if parent page exists.

    // Get all pages at top level.

    // Check if this page is at top level.

    // Get level count(top level as 0).

    // Get all parent pages of the current page.


    // Get all pages with parent-child structure.