vidwan/settings

This package is abandoned and no longer maintained. No replacement package was suggested.

Database Driven Dynamic Settings with Form Builder

v0.0.2 2022-06-15 17:31 UTC

This package is auto-updated.

Last update: 2024-10-14 19:16:04 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Psalm Total Downloads

A Package to generate Dynamic Settings with a Simple Form Builder.

Installation

You can install the package via composer:

composer require vidwan/settings

Usage

Form Builder

File: Vidwan\Settings\Settings

use Vidwan\Settings\Settings;
...
Settings::form(Setting::all())
        ->labelAttributes(['class' => 'form-label'])
        ->inputAttributesFor('text', [
            'class' => 'form-control',
        ])
        ->inputAttributesFor('innerBlock', [
            'checkbox' => [
                'class' => 'form-control',
            ],
        ])
        ->inputAttributesFor('checkbox', function ($settings) {
            return [
                'class' => 'form-check',
            ];
        })
        ->formAttributes(['id' => 'settings-form'])
        ->blockAttributes(['class' => 'mb-1'])
        ->uploadable()
        ->render();

Single Label & Input Builder

use Vidwan\Settings\Models\Setting;

$settings = Setting::all();

foreach ($settings as $setting)
{
    $setting->formLabel(attributes: ['class' => 'something']); // <label></label>
    $setting->formInput(attributes: ['class' => 'form-control']); // <input />
}

Helper

    settings('theme');

Ignoring Migration

Ignoring auto-migrations (without publishing) and specifying the path to publish migrations.

use Vidwan\Settings\Settings;

...

class AppServiceProvider extends ServiceProvider
{
    ...

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // Disable auto-migration
        Settings::$runsMigrations = false;
        // Sets Migration Path
        Settings::$migrationPath = database_path('migrations/tenant');
    }

    ...

}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Support us

You can support us by contributing to our open source projects or Sponsoring the projects you use.

Credits

License

The MIT License (MIT). Please see License File for more information.