Settings
This lets you create a settings page in the admin area and also provides a facade for accessing those settings.
Installation
Add the ServiceProvider to config/app.php.
Yadda\Enso\EnsoSettingsServiceProvider::class,
Add an alias to the Settings Facade.
'EnsoSettings' => Yadda\Enso\Settings\Facades\EnsoSettings::class,
Publish the CRUD.
php artisan vendor:publish
Run the migration to create the enso_settings table.
php artisan migrate
Adding Settings
Settings are managed as any other crud. For example:
class Setting extends BaseCrud
{
public function create(Form $form) {
$form = parent::create($form);
$form
->getSectionByName('main')
->setLabel('Global')
->addField([
(new TextField('some_setting'))
]);
$form->addSections([
(new CollectionSection('social'))
->addFields([
(new TextField('twitter_url')),
(new TextField('instagram_url')),
(new TextField('phone')),
(new TextField('email')),
]);
]);
return $form;
}
}
Accessing Settings
EnsoSettings::get('some_setting', 'Fallback for if some_setting does not exist.');