1. Go to this page and download the library: Download leemason/metable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
leemason / metable example snippets
class User extends Eloquent{
use LeeMason\Metable\HasMeta;
protected $metaModel = 'UserMeta';
}
class UserMeta extends LeeMason\Metable\MetaModel{
// By extending the MetaModel we dont have to set the $fillable or $casts properties!
// Or you can just use the trait
}
$user = new User();
// uses Eloquent firstOrNew to either create or fetch/update the field by "key"
$user->addMeta('key', 'value');
// simple wrapper around addMeta for readability
$user->updateMeta('collection', new Collection(['collection', 'items']));
// need to save lots of data? not a problem
$user->fillMeta([
'meta1' => true,
'meta2' => 200,
'meta3' => [1,2,3],
....
]);
// deleting is easy too
$user->deleteMeta('meta2');
// this will return a Collection object
$collection = $user->getMeta('collection');
// and of course, the meta data are related models so can be accessed, or set as such too
$user->meta();
//or
$user->meta
//and
$meta = new UserMeta();
$meta->key = 'thekey';
$meta->value = 'some value';
$user->meta()->save($meta);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.