PHP code example of jantinnerezo / laravel-model-meta

1. Go to this page and download the library: Download jantinnerezo/laravel-model-meta 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/ */

    

jantinnerezo / laravel-model-meta example snippets



use Jantinnerezo\LaravelModelMeta\Metable;


class YourModel extends Model
{
	use Metable;
}



$yourModel = YourModel::find(1);
$yourModel->setMeta(
	'intro',  // Key
	"Hey Jude, don't make it bad!" // Value
);



$yourModel = YourModel::find(1);
$yourModel->syncMeta([
	'key1' => 'First key',
	'key2' => 'Second key'
]);



$yourModel = YourModel::find(1);
$yourModel->removeMeta('key');



$yourModel = YourModel::find(1);
$yourModel->getMeta('key');



$yourModel = YourModel::find(1);
$yourModel->getMetaOnly(['key1','key2']);



$yourModel = YourModel::find(1);
$yourModel->getAllMeta();