• Stars
    star
    228
  • Rank 169,602 (Top 4 %)
  • Language
    PHP
  • License
    Other
  • Created about 8 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Application settings interface for Backpack (for Laravel 6).

Backpack\Settings

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Style CI Total Downloads

An interface for the administrator to easily change application settings. Uses Laravel Backpack. Works on Laravel 5.2 to Laravel 8.

Security updates and breaking changes

Please subscribe to the Backpack Newsletter so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months.

Install

Note: The default table name is settings, if you need to change it please carefully read the comments in the instruction below.

In your terminal:

# install the package
composer require backpack/settings

# [optional] if you need to change table name or migration name, please do it now before proceding
php artisan vendor:publish --provider="Backpack\Settings\SettingsServiceProvider" --tag="config"
# then change the values you need in in `config/backpack/settings.php`

# publish & run the migration
php artisan vendor:publish --provider="Backpack\Settings\SettingsServiceProvider"
php artisan migrate

# [optional] add a menu item for it to the sidebar_content file
php artisan backpack:add-sidebar-content "<li class='nav-item'><a class='nav-link' href='{{ backpack_url('setting') }}'><i class='nav-icon la la-cog'></i> <span>Settings</span></a></li>"

# [optional] insert some example dummy data to the database
php artisan db:seed --class="Backpack\Settings\database\seeds\SettingsTableSeeder"

Usage

End user

Add it to the menu or access it by its route: application/admin/setting

Programmer

Use it like you would any config value in a virtual settings.php file. Except the values are stored in the database and fetched on boot, instead of being stored in a file.

Setting::get('contact_email')
// or 
Config::get('settings.contact_email')

Add new settings

Settings are stored in the database in the "settings" table. Its columns are:

There is no interface available to add new settings. They are added by the developer directly in the database, since the Backpack CRUD field configuration is a bit complicated. See the field types and their configuration code on https://backpackforlaravel.com/docs

Override existing configurations

You can use this addon to make various Laravel configurations adjustable through the settings GUI, including Backpack settings themself. For example, you can override the Backpack show_powered_by or the skin setting in /config/Backpack/base.php.

  1. Create the setting entry in your settings database. You can add the settings manually, or via Laravel seeders. The values inserted into the database should be look similar to below:

    For Backpack show_powered_by setting:

    Field Value
    key show_powered_by
    name Showed Powered By
    description Whether to show the powered by Backpack on the bottom right corner or not.
    value 1
    field {"name":"value","label":"Value","type":"checkbox"}
    active 1

    For Backpack Skin setting:

    Field Value
    key skin
    name Skin
    description Backpack admin panel skin settings.
    value skin-purple
    field {"name":"value","label":"Value","type":"select2_from_array","options":{"skin-black":"Black","skin-blue":"Blue", "skin-purple":"Purple","skin-red":"Red","skin-yellow":"Yellow","skin-green":"Green","skin-blue-light":"Blue light", "skin-black-light":"Black light","skin-purple-light":"Purple light","skin-green-light":"Green light","skin-red-light":"Red light", "skin-yellow-light":"Yellow light"},"allows_null":false,"default":"skin-purple"}
    active 1
  2. Open up the app/Providers/AppServiceProvider file, and add the below lines:

    <?php
    
    namespace App\Providers;
    
    use Illuminate\Support\ServiceProvider;
    
    class AppServiceProvider extends ServiceProvider
    {
        /**
         * Bootstrap any application services.
         *
         * @return void
         */
        public function boot()
        {
    +       $this->overrideConfigValues();
        }
    
        /**
         * Register any application services.
         *
         * @return void
         */
        public function register()
        {
            //
        }
    
    +   protected function overrideConfigValues()
    +   {
    +       $config = [];
    +       if (config('settings.skin'))
    +           $config['backpack.base.skin'] = config('settings.skin');
    +       if (config('settings.show_powered_by'))
    +           $config['backpack.base.show_powered_by'] = config('settings.show_powered_by') == '1';
    +       config($config);
    +   }
    }

Screenshots

See backpackforlaravel.com

  • List view: List / table view in Backpack/Settings
  • Editing a setting with the email field type:

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Overwriting Functionality

If you need to modify how this works in a project:

  • create a routes/backpack/settings.php file; the package will see that, and load your routes file, instead of the one in the package;
  • create controllers/models that extend the ones in the package, and use those in your new routes file;
  • modify anything you'd like in the new controllers/models;

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Please subscribe to the Backpack Newsletter so you can find out about any security updates, breaking changes or major features. We send an email every 1-2 months.

Credits

License

Backpack is free for non-commercial use and 69 EUR/project for commercial use. Please see License File and backpackforlaravel.com for more information.

Hire us

We've spend more than 50.000 hours creating, polishing and maintaining administration panels on Laravel. We've developed e-Commerce, e-Learning, ERPs, social networks, payment gateways and much more. We've worked on admin panels so much, that we've created one of the most popular software in its niche - just from making public what was repetitive in our projects.

If you are looking for a developer/team to help you build an admin panel on Laravel, look no further. You'll have a difficult time finding someone with more experience & enthusiasm for this. This is what we do. Contact us. Let's see if we can work together.

More Repositories

1

CRUD

Build custom admin panels. Fast!
PHP
2,816
star
2

Base

Until 2018, Backpack v3 used this Base package to offer admin authentication and a blank admin panel using AdminLTE. Backpack v4 no longer uses this package, they're now built-in - use Backpack/CRUD instead.
PHP
891
star
3

PermissionManager

Admin interface for managing users, roles, permissions, using Backpack CRUD
PHP
481
star
4

BackupManager

Admin interface for managing database and file backups in Backpack for Laravel
PHP
305
star
5

demo

A working demo of Laravel with all Backpack packages installed.
PHP
301
star
6

Generators

Generate files for Backpack projects
PHP
296
star
7

PageManager

Administer presentation pages in Laravel, using page templates and Backpack\CRUD
PHP
279
star
8

LogManager

An interface to preview, download and delete Laravel log files, using Backpack.
PHP
261
star
9

NewsCRUD

An admin panel for news with categories and tags, using Backpack CRUD on Laravel 10
PHP
205
star
10

MenuCRUD

An admin panel for menu items, using Backpack\CRUD on Laravel 6 or 7.
Blade
182
star
11

LangFileManager

A quick interface to edit Laravel language files, for Backpack.
PHP
90
star
12

FileManager

Admin interface for files & folders, using elFinder.
PHP
79
star
13

docs

45
star
14

revise-operation

An admin interface for venturecraft/revisionable - audit log for your Eloquent entries.
PHP
42
star
15

basset

Better asset helpers for Laravel apps.
PHP
36
star
16

community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
25
star
17

theme-tabler

UI for Backpack v6 that uses Tabler and Bootstrap v5.
Blade
16
star
18

activity-log

PHP
13
star
19

download-operation

PHP
10
star
20

medialibrary-uploaders

PHP
8
star
21

language-switcher

Multi language dropdown for Backpack v6
PHP
7
star
22

addons

A place for the Backpack community to talk about possible Backpack add-ons.
5
star
23

theme-coreuiv2

UI that uses CoreUI v2 and Bootstrap v4, provided as a legacy theme for Backpack v6.
Blade
4
star
24

theme-coreuiv4

UI for Backpack v6 that uses CoreUI v4 and Bootstrap v5.
Blade
3
star
25

devtools-issues

Bug reports and feature requests for our closed-source DevTools package
3
star
26

legal-documents

All legal documents for the Backpack organisation. Full transparency.
1
star