Skip to content

options

System uses appstract/laravel-options as a base persistent key/value store for a few items.

A subclass of the ‘Option’ class was as in App\Core\Option, which uses the hasMetadata trait. This provides a way to add some more information to the key/value combinations. First use of this is in a UI tool, to provide a small description field.

The Core\Option overrides the Appstract version in AppServiceProvider register() method.

Management of the options is still manual - best handled in migration for the immediate future until there’s a full UI to manage CRUD on options themselves.

Option class is still just an Eloquent model. getModelByKey was added to get the option model by the key. If you have an id, Option::find(id) works as well.

Once a model is retrieved, you can use ->getMeta and ->setMeta operations

$option = Option::getModelByKey('smsClockInReminderMinutes');
$option->value=7;
$option->setMeta('description','Number of minutes before or after a shift starts to remind users');
$option->save();
you can still use the option() call to get/set value, but not manage metadata.

option('smsClockInReminderMinutes','-4')

If an option is intended to be managed from the /admin/options screen, the metadata needs to have ‘ui’:true.

$option = Option::getModelByKey('smsClockInReminderMinutes');
$option->value=7;
$option->setMeta('description', 'Number of minutes before or after a shift starts to remind users');
$option->setMeta('ui', true);
$option->save();

setup

php artisan fix:cats-679
This will instantiate initial values for SMS options.