Download the PHP package matthewbdaly/laravel-flatpages without Composer
On this page you can find all versions of the php package matthewbdaly/laravel-flatpages. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download matthewbdaly/laravel-flatpages
More information about matthewbdaly/laravel-flatpages
Files in matthewbdaly/laravel-flatpages
Package laravel-flatpages
Short Description Laravel flat pages package. Inspired by Django's flatpages
License MIT
Informations about the package laravel-flatpages
laravel-flatpages
A flatpages implementation for Laravel.
Installation
Usage
This package includes not only a model and its associated repository and decorator, but also a controller and view for handling the request. However, it does not include a route - this is because ideally the route for the flat pages should be the very last one in your routes, since it can interfere with other routes. Unless all your flat pages will live under a certain route, you should make sure the route for this is the last one executed, otherwise you will have problems with it. Don't say I didn't warn you!
The controller lives at Matthewbdaly\LaravelFlatpages\Http\Controllers\FlatpageController
and your route should call the page()
method, with the path passed through as the single argument:
Alternatively, you can use the middleware at Matthewbdaly\LaravelFlatpages\Http\Middleware\FlatpageMiddleware
, which may be more convenient. Be aware it will run on every 404 response received, and it should be set as the last global middleware.
Overriding the view
The default view used is flatpages::base
, but this almost certainly isn't what you want, so you'll need to create a new version in your project at resources\views\vendor\flatpages\base
. Obviously this can extend or include other views in the usual manner.
Every flatpage object has a template
field. This defaults to null, which will use flatpages::base
, but you can set it to point at any other view you want to use. Your view will obviously need to use the same variables as the default one, but using this method you can create multiple views that can be used by one or more templates, meaning that part of the content can be kept in the view and part in the database. This makes the package more flexible in that you can choose which content users can manage themselves and which you can control.