PHP code example of larastash / options
1. Go to this page and download the library: Download larastash/options 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/ */
larastash / options example snippets
use Larastash\Options\Option;
$option = app('option');
$option = app(Option::class);
Option::set('key', 'value');
// Set an option with a TTL of 1 hour
Option::set('key', 'value', 3600);
Option::set('key', 'value', now()->addHour());
$value = Option::get('key');
$value = Option::get('key', 'default');
// Retrived value will be cached for 1 hour
$value = Option::get('key', 'default', 3600);
$value = Option::get('key', 'default', now()->addHour());
Option::remove('key');
if (Option::exists('key')) {
// Option exists
} else {
// Option does not exist
}
$options = Option::all();
$query = Option::query();
$query = Option::query();
$query->where('key', 'like', 'prefix%');
$options = $query->get();
$value = option('key', 'default value');
$value = option('key', 'default value', ttl: 3600);
$value = option('key', 'default value', ttl: now()->addHour());
option(['key' => 'new value']);
option(['key' => 'new value'], ttl: 3600);
option(['key' => 'new value'], ttl: now()->addHour());
// or as array list
option(['key', 'new value']);
option(['key', 'new value'], ttl: 3600);
option(['key', 'new value'], ttl: now()->addHour());
$option = option();
option()->set(...);
option()->get(...);
option()->remove(...);
option()->exists(...);
option()->query(...);
// and etc...
shell
php artisan migrate