Package Data | |
---|---|
Maintainer Username: | gbrock |
Package Create Date: | 2015-03-23 |
Package Last Update: | 2015-08-20 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-22 03:00:34 |
Package Statistics | |
---|---|
Total Downloads: | 259 |
Monthly Downloads: | 2 |
Daily Downloads: | 1 |
Total Stars: | 11 |
Total Watchers: | 3 |
Total Forks: | 3 |
Total Open Issues: | 1 |
A Laravel 5.1 package designed to add pages to your Laravel application. A page is just content defined by specific URL, or slug. A page may or may not be published.
Run composer require gbrock/laravel-pages
from your project directory.
Add the service provider to the providers
array in config/app.php
:
Gbrock\Pages\Providers\PageServiceProvider::class,
Publish the migrations, views, and config file:
php artisan vendor:publish --provider="Gbrock\Pages\Providers\ContactableServiceProvider"
Run the migrations:
php artisan migrate
Create a Page model:
\Gbrock\Pages\Models\Page::create([
'title' => 'Hello, World',
'content' => '<p>Hi everybody</p>',
'public' => true,
]);
...which is now accessible by browsing to /hello-world
!
A domain is a set of pages which are always under a specific slug. For example, you might make a "BlogPage" model
whose members are always accessible under blog/{slug}
:
<?php
namespace App;
use Gbrock\Pages\Models\Page;
use Gbrock\Pages\Traits\Domainable;
class BlogPage extends Page {
use Domainable;
protected static $domain = 'blog';
}
Then you can query that model for only that domain of pages. Please note that, by default, domained pages will be
included in queries when using the above Page model. In order to ignore domained pages, extend the included Page model
and add ignorable domains to the $subdomains
property:
<?php
namespace App;
use Gbrock\Pages\Models\Page as BasePage;
class Page extends BasePage
{
protected static $subdomains = ['blog'];
}