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 for the metadata of different Laravel projects.
Install via composer
Run the following command to pull in the latest version:
Documentation
Undergoing continuous enhancements, this package evolves each day, integrating an array of diverse features. It stands as an indispensable asset for enthusiasts of Laravel, offering a seamless way to harmonize their projects with metadata database models.
In this package, you can employ it seamlessly with any model requiring database metadata.
Now, let's delve into the core functionality.
Before doing anything, you must migrate after installing the package by composer.
Meet the HasMeta
class, meticulously designed for integration into your model. This class automates essential tasks, ensuring a streamlined process for:
In the first step, you need to connect this class to your main model.
When you add this class, you will have to implement MetaContract
to your model.
Now you have to use the metadataAllowFields function, and you have to add it to your model.
This function is for you to declare what translation fields you need for this model, and you should return them here as an
array
.
How is it used?
Metaable trait
To make the above process easier, you can add the Metaable trait to the User class, which you can do as follows.
How does this trait work?
setMeta
To set metadata, you can use the following code.
getMeta
To get metadata, you can use the following code.
You can do this manually, this code is used when you want to write dynamic code.
Store metadata
To store metadata, you can use the following code.
Forget metadata
To forget metadata, you can use the following code.
Forget all metadata
To forget all metadata, you can use the following code.
Get metadata
To get metadata, you can use the following code.
Get all metadata
To get all metadata, you can use the following code.
Has metadata
To check if metadata exists, you can use the following code.
Events
This package contains several events for which you can write a listener as follows
Event | Description |
---|---|
MetadataStoredEvent |
This event is called after storing the metadata. |
MetadataForgetEvent |
This event is called after forgetting the metadata. |
Contributing
Thank you for considering contributing to the Laravel Metadata! The contribution guide can be found in the CONTRIBUTING.md.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-metadata with dependencies
laravel/framework Version >=9.19
jobmetric/laravel-package-core Version ^1.2