Download the PHP package dhcmega/laravel-meta without Composer

On this page you can find all versions of the php package dhcmega/laravel-meta. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-meta

Fluent Meta Data for Eloquent Models

Laravel Source Build Status License

Metable Trait adds the ability to access meta data as if it is a property on your model. Metable is Fluent, just like using an eloquent model attribute you can set or unset metas. Follow along the documentation to find out more.

Installation

Composer

Add this to your composer.json file, in the require object:

After that, run composer install to install the package.

Migration Table Schema

Configuration

Model Setup

Next, add the Metable trait to each of your metable model definition:

Metable Trait will automatically set the meta table based on your model name. Default meta table name would be, model_meta. In case you need to define your own meta table name, you can specify in model:

Default Model Attribute values

Additionally, you can set default values by setting an array called $defaultMetaValues on the model. Setting default has two side-effects:

  1. If a meta attribute does not exist, the default value will be returned instead of null.

  2. if you attempt to set a meta attribute to the default value, the row in the meta table will be removed, which will cause the default value to be returned, as per rule 1.

This is be the desired and expected functionality for most projects, but be aware that you may need to reimplement default functionality with your own custom accessors and mutators if this functionality does not fit your needs.

This functionality is most suited for meta entries that note exceptions to rules. For example: employees sick out of office (default value: in office), nodes taken down for maintance (default value: node up), etc. This means the table doesn't need to store data on every entry which is in the expected state, only those rows in the exceptional state, and allows the rows to have a default state upon creation without needing to add code to write it.

Gotcha

When you extend a model and still want to use the same meta table you must override getMetaKeyName function.

Working With Meta

Setting Content Meta

To set a meta value on an existing piece of content or create a new data:

Fluent way, You can set meta flawlessly as you do on your regular eloquent models. Metable checks if attribute belongs to model, if not it will access meta model to append or set a new meta.

Or

Or set multiple metas at once:

Or set multiple metas and columns at once:

Note: If a piece of content already has a meta the existing value will be updated.

Unsetting Content Meta

Similarly, you may unset meta from an existing piece of content:

Fluent way to unset.

Or

Or unset multiple metas at once:

Note: The system will not throw an error if the content does not have the requested meta.

Checking for Metas

To see if a piece of content has a meta:

Fluent way, Metable is clever enough to understand $post->content is an attribute of meta.

Retrieving Meta

To retrieve a meta value on a piece of content, use the getMeta method:

Fluent way, You can access meta data as if it is a property on your model. Just like you do on your regular eloquent models.

Or

Or specify a default value, if not set:

You may also retrieve more than one meta at a time and get an illuminate collection:

Retrieving All Metas

To fetch all metas associated with a piece of content, use the getMeta without any params

Retrieving an Array of All Metas

To fetch all metas associated with a piece of content and return them as an array, use the toArray method:

Meta Table Join

When you need to filter your model based on the meta data , you can use meta scope in Eloquent Query Builder.

Eager Loading

When you need to retrive multiple results from your model, you can eager load metas

Prevent metas attribute from being populated

When you convert a model to an array (or json) and you don't need all meta fields, you can create a model's property to prevent metas from being added to the resulting array. You can also use it on eloquent relations.


All versions of laravel-meta with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version ~5.0|~5.1|^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dhcmega/laravel-meta contains the following files

Loading the files please wait ....