PHP code example of vidwan / settings

1. Go to this page and download the library: Download vidwan/settings library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vidwan / settings example snippets


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();

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 />
}

    settings('theme');


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');
    }

    ...

}