Download the PHP package belyaevad/laravel-meta without Composer
On this page you can find all versions of the php package belyaevad/laravel-meta. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download belyaevad/laravel-meta
More information about belyaevad/laravel-meta
Files in belyaevad/laravel-meta
Package laravel-meta
Short Description Model meta
License MIT
Homepage https://github.com/belyaevad/laravel-meta
Informations about the package laravel-meta
Laravel Meta
Metadata for your Eloquent model (WordPress analogy).
The idea of creating a package was borrowed from the WordPress CMS, where each entry in the wp_posts
table can have as many additional fields as you want.
The mechanism for storing and receiving data is implemented on the morphTo
relation. All meta data is stored in a separate table and connected to your model via a trait.
By default, the metadata is not loaded with the model, but this can be fixed by adding meta
to the auto-loading relationship:
or load in collection
Any reading of the meta-data performs a single load of all meta-fields associated with your model, which saves you from many sql queries
If you need reload meta-data – use $post->metaReLoad()
method.
Installation
You can install the package via composer:
Publish, migrate
By running php artisan vendor:publish --provider="BelyaevAD\Meta\MetaServiceProvider"
in your project all files for this package will be published. For this package, it's only a migration. Run php artisan migrate
to migrate the table. There will now be a table named metas
in your database.
Usage
You can easily add Meta to an Eloquent model. Just add this to your model:
Then you can get, add, update and delete meta to the you model.
Testing
Contributing
Contributions are welcome, thanks to y'all :)
License
The MIT License (MIT). Please see License File for more information.