Trait and model to attach meta data to Eloquent models. Developed for ScubaClick and is considered stable now!
v1.0.1
Install by adding the following to the require block in composer.json:
"scubaclick/meta": "1.*"
Then run composer update
.
php artisan migrate --package="scubaclick/meta"
Add the trait to all models that you want to attach meta data to:
use Illuminate\Database\Eloquent\Model;
class SomeModel extends Model
{
use \ScubaClick\Meta\MetaTrait;
// model methods
}
Then use like this:
$model = SomeModel::find(1);
$model->getAllMeta();
$model->getMeta('some_key');
$model->updateMeta('some_key', 'New Value');
$model->deleteMeta('some_key');
$model->deleteAllMeta();
$model->addMeta('new_key', ['First Value']);
$model->appendMeta('new_key', 'Second Value');
ScubaClick Meta is licenced under the MIT license.