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/ */
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