Download the PHP package leemason/metable without Composer
On this page you can find all versions of the php package leemason/metable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leemason/metable
More information about leemason/metable
Files in leemason/metable
Package metable
Short Description The Laravel Eloquent Metable Package is designed specifically for associating meta information to an Eloquent model.
License MIT
Informations about the package metable
Laravel Metable Package
The Laravel Eloquent Metable Package is designed specifically for associating "meta" information to an Eloquent model.
Installation
Just place require new package for your laravel installation via composer.json
Then hit composer update
Compatability
The Metable package has been developed with Laravel 5.1, i see no reason why it wouldnt work with 5.0 or even 4 but it is only tested for 5.1.
Introduction
There are many use cases for this, most notably a User model where you may need the ability to assign multiple different types of profile information.
Ideally you would always provide unique columns on your model tables to handle all of the data, but in more dynamic applications this may not always be a viable option.
This is were "meta" information comes into its own.
This package provides the means to associate any kind of data to a model, from ints, float, bools, arrays, to Collections and objects.
Not only does it make it easy to assign this data, it also formats the data for the database and on return usage.
For example a User may need multiple social links, with this package you can create a collection with the data, save right there and then as a Collection (which gets saved as json encoded string). Then whenever its retrieved in the future it will be converted back to a Collection.
The "meta" is saved as related Eloquent models with simple key/value access.
In the background the meta model also saved the values "type" for use when returning.
The package comes with 2 traits which adds all the functionality needed and a few helpers to make managing the information even easier.
The trait is used to turn an Eloquent model into a meta model and provides all the background logic for formatting the meta value.
Then the main functionality is accessed through the trait.
Here are a few examples (checkout the docs folder for more details information).