PHP code example of parabellumkoval / backpack-settings

1. Go to this page and download the library: Download parabellumkoval/backpack-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/ */

    

parabellumkoval / backpack-settings example snippets




namespace App\Settings;

use Backpack\Settings\Contracts\SettingsRegistrarInterface;
use Backpack\Settings\Services\Registry\Registry;
use Backpack\Settings\Services\Registry\Field;

class StoreSettingsRegistrar implements SettingsRegistrarInterface
{
    public function register(Registry $registry): void
    {
        $registry->group('store', function ($group) {
            $group->title('Магазин')->icon('la la-store')
                ->page('Общее', function ($page) {
                    $page->add(Field::make('store.products.modifications.enabled', 'checkbox')
                        ->label('Включить модификации')
                        ->default(false)
                        ->cast('bool')
                        ->tab('Основное')
                    );
                    $page->add(Field::make('store.products.modifications.mode', 'select')
                        ->label('Режим модификаций')
                        ->options(['vertical' => 'Вертикальные', 'flat' => 'Плоские'])
                        ->default('vertical')
                        ->cast('string')
                        ->tab('Расширенные')
                    );
                })
                ->page('Оплата', function ($page) {
                    $page->add(Field::make('store.payment.cod_enabled', 'toggle')
                        ->label('Наложенный платеж')
                        ->default(true)
                        ->cast('bool')
                    );
                });
        });
    }
}

'registrars' => [
    App\Settings\StoreSettingsRegistrar::class,
],

use Backpack\Settings\Facades\Settings;

if (Settings::get('store.products.modifications.enabled')) {
    // ...
}

return [
    'available_locales' => ['en' => 'English', 'ru' => 'Русский'],
    'available_regions' => ['de' => 'Germany', 'pl' => 'Poland'],
    'locale_query_parameter' => 'locale',
    'region_query_parameter' => 'country',
];
bash
composer vendor:publish --provider="Backpack\Settings\Providers\BackpackSettingsServiceProvider" --tag=config
php artisan vendor:publish --provider="Backpack\Settings\Providers\BackpackSettingsServiceProvider" --tag=migrations
php artisan migrate