PHP code example of belyaevad / laravel-meta

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

    

belyaevad / laravel-meta example snippets


protected $ with = [
    // ...
    // other relationships
    'meta',
];

$postList = Post::where('active', true)->with('meta')->get();

use BelyaevAD\Meta\Metable;

class Post extends Model
{
    use Metable;
}

$post = Post::find(1);

$post->addMeta('someKey', 'someValue');

$post->getMeta('someKey');

$post->getMetaValue('someKey');

$post->hasMeta('someKey');

$post->updateMeta('someKey', 'anotherValue');

$post->addOrUpdateMeta('someKey', 'someValue');

$post->deleteMeta('someKey');

$post->getAllMeta();

$post->deleteAllMeta();

$post->metaReLoad();