Data Store
Lightweight key-value storage for modules.
The Data Store provides small, structured storage for settings and module data.
Drivers #
| Driver | Description |
|---|---|
file |
JSON files in storage |
database |
Table data_store |
auto |
Prefers DB for reads, writes to both; file fallback |
Usage #
Use app('data') or inject DataStore.
$data = app('data');
API #
put() #
Store a value in a collection.
$data->put('menus', 'primary', ['items' => []]);
get() #
Retrieve a value from a collection.
$menu = $data->get('menus', 'primary');
has() #
Check if a key exists.
if ($data->has('menus', 'primary')) {
// ...
}
forget() #
Remove a key from a collection.
$data->forget('menus', 'primary');
all() #
Get all entries in a collection.
$allMenus = $data->all('menus');
filter() #
Filter entries with a predicate.
$published = $data->filter('posts', fn($item) => $item['status'] === 'published');
clear() #
Remove all entries from a collection.
$data->clear('cache');
Auto driver behavior #
The auto driver writes to both file and database when available, and prefers database reads when possible.