seyedmr / laralight-metadata
a light package for adding meta-data to laravel projects
Installs: 41
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 1
Type:laravel-package
This package is not auto-updated.
Last update: 2024-06-15 06:54:34 UTC
README
Laralight Metadata
laralight-metadata package created for those projects need to have metadata. i named this to laralight becouse this package is so light and also created for 'lara'vel.
i created a lot light package for laravel and i'll add them to my git soon.
Installing
composer require seyedmr/laralight-metadata
php artisan migrate
Congrat , you done it.
Usage
as i said before , this package is too light and easy to use.
Prepare your model
Add this trait to the model that you want that to have metadata.
SeyedMR\LaraliteMetadata\Traits\HasMeta
For example (User):
namespace App; ... use Illuminate\Database\Eloquent\Model; use SeyedMR\LaraliteMetadata\Traits\HasMeta; class User extends Model { use HasMeta; ... }
And now your model is ready to have metadata.
Adding metadata
for adding metadata you just need to use this method.
$model->setMeta('meta-key','meta-value');
For example :
$user = User::find(1); $user->setMeta('meta-key','meta-value');
Getting metadata
Getting metadata is easy too.
For example :
$user = User::find(1); $user->getMeta('meta-key');