1. Go to this page and download the library: Download vkovic/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/ */
vkovic / laravel-meta example snippets
// Set meta value as string
Meta::set('foo', 'bar');
// Get meta value
Meta::get('foo')) // : 'bar'
// In case there is no metadata found for given key,
// we can pass default value to return
Meta::get('baz', 'default'); // : 'default'
Meta::set('settings.display.resolution', '1280x1024');
Meta::set('settings.display.brightness', 97);
Meta::set('settings.sound.volume', 54);
Meta::set('settings.mic.volume', 0);
Meta::query('settings.display.*');
// Result:
// [
// 'settings.display.resolution' => '1280x1024',
// 'settings.display.brightness' => 97
// ]
Meta::query('*.sound.*');
// Result:
// [
// 'settings.sound.volume' => 54
// ]
Meta::query('settings.*.volume');
// Result:
// [
// 'settings.sound.volume' => 54,
// 'settings.mic.volume' => 0
// ]
// In case there is no metadata found for given query,
// we can pass default value to return
Meta::query('settings.sound.bass', 85); // : 85
Meta::set('a', 'one');
Meta::set('b', 'two');
Meta::set('c', 'three');
// Get all metadata
Meta::all(); // : ['a' => 'one', 'b' => 'two', 'c' => 'three']
// Get only keys
Meta::keys(); // : [0 => 'a', 1 => 'b', 2 => 'c']
Meta::set('a', 'one');
Meta::set('b', 'two');
Meta::set('c', 'three');
// Remove meta by key
Meta::remove('a');
// Or array of keys
Meta::remove(['b', 'c']);
// This will delete all metadata from our meta table!
Meta::purge();
Meta::getModel();
bash
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.