PHP code example of boxed-code / laravel-eloquent-meta

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

    

boxed-code / laravel-eloquent-meta example snippets


composer 

BoxedCode\Eloquent\Meta\MetaServiceProvider::class

php artisan make:meta-migration

php artisan migrate

class MyModel extends Model
{
    use Metable;
}

...

$model = new MyModel();

// Access via magic accessors on the meta collection.

$model->meta->foo = 'bar';

echo $model->meta->foo; // prints 'bar'

// Access via the collection

$item = $model->meta->whereKey('foo')->first();

echo $item; // prints 'bar'



use BoxedCode\Eloquent\Meta\FluentMeta;
use Illuminate\Database\Eloquent\Model;

class MyModel extends Model
{
    use FluentMeta;
}

...

$model = new MyModel();

// Access via magic accessors on the model.

$model->foo = 'bar';

echo $model->foo; // prints 'bar'

// Access via the collection

$item = $model->meta->whereKey('foo')->first();

echo $item; // prints 'bar'