PHP code example of skotner / laravel-meta

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

    

skotner / laravel-meta example snippets


$model->setMeta('foo', 'bar');
$model->getMeta('foo'); // Returns 'bar'

$model->setMeta([
	'animal' => 'sheep',
	'flower' => 'rose',
	'drink'  => 'milk'
]);

return [

	/*
	* Table name where the meta tags are stored.
	*/
	'table_name' => 'meta',
	
];

use Illuminate\Foundation\Auth\User as Authenticatable;
use Skotner\Meta\Meta;

class User extends Authenticatable
{
    use Meta;

    // ...
}

// Adding a single meta tag
$user->setMeta('foo', 'bar');

// Adding multiple meta tags at once
$user->setMeta([
	'animal' => 'sheep',
	'flower' => 'rose',
	'drink'  => 'milk'
]);

$user->getMeta('foo'); // Will return "bar" if set as above, or will return null if it doesn't exist

$user->deleteMeta('foo'); // Deletes the meta tag with key "foo" if it exists
bash
php artisan vendor:publish --provider="Skotner\Meta\MetaServiceProvider"
bash
php artisan migrate