Download the PHP package optimuscms/meta without Composer
On this page you can find all versions of the php package optimuscms/meta. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download optimuscms/meta
More information about optimuscms/meta
Files in optimuscms/meta
Package meta
Short Description Store meta data for the web against your Laravel Models
License
Informations about the package meta
Meta
Provides a standardised approach to attaching website meta data to Laravel Models. Typically this is used for entities such as Pages, Blog Posts, Events, etc, which will need fields like 'Meta Title', 'Meta Description', and 'OG Image' when they are presented on the web.
Installation
You can install the package via composer:
Once installed, you should add the tables used by this package to your database:
Key concepts
There are a few key concepts that should be understood before continuing:
-
A new model called Meta will be attached to whichever Models you define as requiring meta data.
-
It is a 'has one' relationship where the Model can have zero or one Meta Model attached to it.
- The Meta Model depends on the optimuscms/media package in order to attach images to it.
Usage
-
Add the
HasMeta
trait to whatever Model you want to collect meta data for: -
Add a boot method to your Model (if it doesn't already exist) with the following content:
-
(Optional) If your Model appears in an API response, you'll want to add the meta property (either to the Model directly, or in a Resource class if you're using one):
-
When creating or updating your model (eg. from a CMS action), make sure your form submits its request in the following format:
All fields are optional and this package will automatically pick them up and process them as required.
Retrieving OG images
This package also provides a convenient way to retrieve the OG image as a Media Model:
License
The MIT License (MIT). Please see License File for more information.
All versions of meta with dependencies
laravel/framework Version 5.5.*|5.6.*|5.7.*|5.8.*
optimuscms/media Version ^0.2.0