Download the PHP package jobmetric/laravel-metadata without Composer
On this page you can find all versions of the php package jobmetric/laravel-metadata. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jobmetric/laravel-metadata
More information about jobmetric/laravel-metadata
Files in jobmetric/laravel-metadata
Package laravel-metadata
Short Description This package is for the metadata of different Laravel projects.
License MIT
Informations about the package laravel-metadata
Metadata for Laravel
This package is designed to manage metadata in Laravel projects.
Install via Composer
Documentation
This package offers a robust and flexible metadata system for Laravel Eloquent models, enabling you to attach dynamic key-value data through a morphMany
relationship. It supports full control over metadata keys, validation, events, and batch operations.
Migrate database
Before using the package, run:
How to use
Attach Trait to Model
Add the HasMeta
trait to your model:
Optional: Limit Allowed Metadata Keys
To restrict metadata keys, define a protected array $metadata = [...]
in your model:
If omitted or set as ['*']
, all keys are allowed.
API Usage
Store metadata
Store multiple metadata
Retrieve a metadata value
Retrieve all metadata
Check if metadata exists
Delete specific metadata
Delete all metadata
Allow additional metadata keys at runtime
Remove allowed metadata key
Events
This package includes events for metadata operations:
Event | Description |
---|---|
MetadataStoringEvent |
Before metadata is stored |
MetadataStoredEvent |
After metadata is stored |
MetadataDeletingEvent |
Before metadata is deleted |
MetadataDeletedEvent |
After metadata is deleted |
You may listen to these events to customize your logic.
Advanced Notes
- If you define
$metadata
in the model, it overrides the default['*']
. - During model
saving
, metadata is validated against allowed keys. - You can interact with the
metas()
relationship directly for advanced queries. - All metadata values that are arrays are stored as JSON in the DB.
Contributing
Thank you for considering contributing to Laravel Metadata! See the CONTRIBUTING.md for details.
License
The MIT License (MIT). See the License File for details.
All versions of laravel-metadata with dependencies
laravel/framework Version >=9.19
jobmetric/laravel-package-core Version ^1.22
jobmetric/laravel-custom-field Version ^1.7