Preface
Introduction
A Platform 3 extension to manage, publish and maintain pages across your application.
Have a read through the Installation Guide.
Features
- create, update or delete pages.
- assign name & slug.
- set https/http.
- enable/disable.
- set automatically routable URI's.
- set storage type, either database or filesystem.
- set template inheritance.
- set blade section.
- set visibility (show always, logged in or admin).
- restrict access by roles.
- set menu navigation.
- add tags.
- add attributes.
Examples
The $pages
variable used below is a reference to the PageRepository.
$pages = app('platform.pages');
Retrieve all pages
$allPages = $pages->findAll();
Dynamically create a new page.
$pages->create([
'name' => 'Foo',
'slug' => 'foo',
'uri' => 'foo',
'enabled' => true,
'type' => 'filesystem',
'visibility' => 'always',
'file' => 'foo',
]);
Setup
Installation
The best and easiest way to install the Pages extension is with Composer.
Preparation
Open your composer.json
file and add the following to the require
array:
"platform/pages": "2.0.*"
Add the following lines after the require
array on your composer.json
file:
"repositories": [
{
"type": "composer",
"url": "https://packages.cartalyst.com"
}
]
Note: Make sure that after the required changes your
composer.json
file is valid by runningcomposer validate
.
Install the dependencies
Run Composer to install or update the new requirement.
php composer install
or
php composer update
Now you are able to install the extension through Platform's admin.
Usage
In this section we'll show how you can manage your pages.
Repository
IoC Binding
The page repository is bound to platform.pages
and can be resolved out of the IoC Container using that offset.
$pages = app('platform.pages');
Methods
The repository contains several methods that are used throughout the extension, most common methods are listed below.
For an exhaustive list of available methods, checkout the PageRepositoryInterface
- findAll();
Returns a collection of all pages.
- findAllEnabled();
Returns a collection of all enabled pages.
- find($id);
Returns a page object based on the given id.
- findBySlug($slug);
Returns a page object based on the given slug.
- findByUri($uri);
Returns a page object based on the given uri.
- findEnabled($id);
Returns a page object based on the given id and being enabled.
- create(array $data);
Creates a new page.
- update($id, array $data);
Updates an existing page.
- delete($id);
Deletes a page.
- enable($id);
Enables a page.
- disable($id);
Disables a page.
- render(Page $page);
Renders a page for output.