Skip to content

seyedmr/laralight-metadata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laralight Metadata

laralight-metadata package created for those projects need to have metadata. i named this to laralight because 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

  1. composer require seyedmr/laralight-metadata
  2. 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');

About

a laravel package for adding meta data to models

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages