Skip to content

Ladmin Option

Asep edited this page Apr 5, 2022 · 3 revisions

You can save data into Ladmin Option if at any time needed, the system works like a cache but it was stored in the database and cache and will always sync, if the cache is not found then the data will be retrieved from the database and re-syncronized.

Save and modify data

ladmin()->setOption('foo', 'bar');
// Input String

Can also store array data

ladmin()->setOption('foo', ['bar' => 'baz']);
// Input Array

Retrieve data

ladmin()->getOptoin('foo', 'default value');
// Output String | Array

Delete data

ladmin()->deleteOptoin('foo');
// Output Boolean

Checking data

ladmin()->hasOptoin('foo');
// Output Boolean

Inline Method

In addition to the above method, you can also use the options($method, $key, $value) method, and the available methods include has|get|set|delete. See the example below.

ladmin()->option('set', 'foo', ['bar' => 'baz']);

Cache

If you don't want to store it in cache, you can disable it via the config file config/ladmin.php

. . .
'option' => [
    'cache' => [
        'enable' => false,
        'driver' => env('CACHE_DRIVER')
    ]
]
. . .

For the driver cache is fetched based on the default cache of laravel .env, you can also change it in the config file as above.