An interface for the administrator to easily change application settings. Uses Laravel Backpack

Related tags

Laravel Settings
Overview

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:

Settings" # [optional] insert some example dummy data to the database php artisan db:seed --class="Backpack\Settings\database\seeds\SettingsTableSeeder"">
# 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 ""

# [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:

    +       $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.

Comments
  • Config::get not working on a Command Extension

    Config::get not working on a Command Extension

    This is my command extension file:

    <?php
    
    namespace App\Console\Commands;
    use Illuminate\Support\Facades\Mail;
    use Illuminate\Support\Facades\Config;
    use App\Mail\Recurr;
    
    use Illuminate\Console\Command;
    
    class SendEmails extends Command
    {
        /**
         * The name and signature of the console command.
         *
         * @var string
         */
        protected $signature = 'email:send';
    
        /**
         * The console command description.
         *
         * @var string
         */
        protected $description = 'send email';
    
        /**
         * Create a new command instance.
         *
         * @return void
         */
        public function __construct()
        {
            parent::__construct();
        }
    
        /**
         * Execute the console command.
         *
         * @return mixed
         */
        public function handle()
        {            
            $this->info('Email: ' . Config::get('settings.contact_email_unpaid'));
        }
    }
    

    The idea is to send an email to the email configured.

    Outputs Email: (null) for some reason..

    opened by madd86 10
  • Set value programatically?

    Set value programatically?

    If I do this, I don't get "hola1" only after the the second request I get proper value.

    route::get('test',function(){
        Backpack\Settings\app\Models\Setting::where('key','MP_TOKEN')->update([
        'value'=>'hola1',
        ]);    
        echo Config::get('settings.MP_TOKEN');
    });
    

    wouldn't it be easier to have a

    Config::set('key',value);

    to store value properly?

    question 
    opened by eduardoarandah 8
  • Error when using MongoDB

    Error when using MongoDB

    If you try to composer require backpack/settings and you have MongoDB as default DB, you get this error

    PHP Fatal error: Call to a member function prepare() on null in /Users/Dev/laravel/backpack/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 333

    I think it's related to this: https://github.com/jenssegers/laravel-mongodb/issues/888

    opened by elfeffe 8
  • Working fine with mysql but fail on postgreSQL

    Working fine with mysql but fail on postgreSQL

    Hi, first want to thank you for these very useful packages but I get errors when working with a postgreSQL database. Here when I try to install the migration files for the settings package I got this error.

    SQLSTATE[42601]: Syntax error: 7 ERREUR: syntax error near LIKE LINE 1: SHOW TABLES LIKE 'settings' ^ (SQL: SHOW TABLES LIKE 'settings')

    But with MySQL everything is working fine.

    bug 
    opened by pacobabs 8
  • Unable to edit using user interface

    Unable to edit using user interface

    Problem

    On settings interface I click on the 'edit' button of the row I wanna edit. I add the text and click save, doesn't save.

    This is what my DB looks like

    This is what my DB looks like

    If I add a value there, and then go to the user interface, I see that value on the list view, but not on the form view.

    opened by madd86 7
  • Add Config for Table name and Route Path

    Add Config for Table name and Route Path

    The update goal is allow user change the settings table name and route path. Even though normal case it will use default value. For my case, I use another settings package by spatie, and it conflict with backpack table name and route. Hence, I make this update, so allow other user to do some customisation in their setting.

    1. I added config/settings.php, allow to change the default table name and route.
    2. Change migration to migration stub so can generated by current time
    3. vendor:publish added publish config file, if not publish will use default value.

    First PR to backpack.

    enhancement 
    opened by shiroamada 6
  • Settings don't register in the console

    Settings don't register in the console

    Bug report

    Settings don't get loaded when running console apps. This is giving me problems with my Functional Testing.

    I'd be interested to know why CLI is excluded, and whether it can be enabled?

    What I did:

    Setup as instructed, everything is working. I then tried to run FunctionalTests using PHPBrowser (via CodeCeption).

    What I expected to happen:

    For my settings to be available in all versions of the app.

    What happened:

    The settings don't get loaded because Backpack\Settings\SettingsServiceProvider::boot() specifically excludes loading them when running on the command line.

    What I've already tried to fix it:

    I've changed: if (!\App::runningInConsole() && count(Schema::getColumnListing('settings'))) { to if (count(Schema::getColumnListing('settings'))) {

    (removing !\App::runningInConsole() &&) and it's now working as expected.

    Backpack, Laravel, PHP, DB version:

    Settings: 2.1.2 Backpack CRUD: 3.5.10 Laravel: 5.7.16 PHP: 7.2

    triage 
    opened by Patabugen 6
  • Fixed error with field attributes

    Fixed error with field attributes

    Plain casting to an array does not convert nested arrays, which causes attributes parameter remained as stdClass by default.

    This PR fixes that behavior, making attributes an actual array that doesn't break edit page.

    opened by adriandmitroca 6
  • Latest version cannot be used with CRUD 3.3

    Latest version cannot be used with CRUD 3.3

    Bug report

    What I did:

    Follow the steps to upgrade to CRUD 3.3

    What I expected to happen:

    Latest version of this package to install (2.0.24)

    What happened:

    Some old version was installed (2.0.8)

    What I've already tried to fix it:

    The dependency in composer.json is specified as "3.2.", it should be "3.2.|3.3.*" or something like "^3.2.0". It might solve some other issues, like #58 and #59.

    Backpack, Laravel, PHP, DB version:

    0.8, 5.5, 7.0, MariaDB 10.1

    opened by paneidos 6
  • DataTable warning after update to Backpack 3.3

    DataTable warning after update to Backpack 3.3

    Bug report

    Got an alert with DataTable warning: table_id=crudTable Ajax Error

    What I did:

    updated to Backpack 3.3

    What I expected to happen:

    Show my settings table

    What happened:

    What I've already tried to fix it:

    Followed the link in the alert

    Backpack, Laravel, PHP, DB version:

    Backpack 3.3 Laravel 5.5.21 Php 7.1

    opened by remipou 6
  • [Bug Fix] Prevents DB Queries running when Artisan is running commands

    [Bug Fix] Prevents DB Queries running when Artisan is running commands

    Running the DB queries clashes with artisan cli when no database is available.

    Meaning you cannot install/run artisan without setting up a database which makes deploying with systems like Envoyer, Codeship, Deploybot impossible.

    opened by OwenMelbz 6
  • Always overwrite Field name attribute to Value

    Always overwrite Field name attribute to Value

    WHY

    In documentation it says: field (Backpack CRUD field configuration in JSON format. https://backpackforlaravel.com/docs/crud-fields#default-field-types)

    As new to backpack, I lost an hour trying to figure it out Why my settings weren't working while I was setting field name to title or logo or whatever.

    BEFORE - What was wrong? What was happening before this PR?

    If somebody writes field name to something else than value, the update operation isn't working.

    AFTER - What is happening after this PR?

    We make sure always field name is set to value

    How did you achieve that, in technical terms?

    Always overwriting $field['name'] = 'value';

    Is it a breaking change or non-breaking change?

    Non-breaking change

    How can we test the before & after?

    ??

    opened by Bojmaliev 1
  • How to setup repeatable field

    How to setup repeatable field

    Bug report

    What I did:

    What I expected to happen:

    {"name":"value","label":"Job Progress and Timeline", "title":"Timeline", "type":"repeatable","fields": {{"name": "job","type": "text"},{"name": "createdate","type": "datetime"}}}

    What happened:

    ErrorException Trying to access array offset on value of type null

    What I've already tried to fix it:

    Backpack, Laravel, PHP, DB version:

    PHP VERSION:

    PHP 7.4.8 (cli) (built: Jul 9 2020 11:30:39) ( ZTS Visual C++ 2017 x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies

    LARAVEL VERSION:

    v7.22.4@30e851a2b3a2af73fba0b7f4fa22b04260db98e7

    BACKPACK VERSION:

    4.1.15@6c751de946a9c8511dd32eb7bfa3ca6a568849f5

    opened by gumpon 2
  • Settings syncronization with config/settings.php

    Settings syncronization with config/settings.php

    Settings syncronization with config/settings.php

    Command settings:sync helps you keep production settings in sync with config/settings.php It doesn't override "value" field

    Package now publishes config/settings.php

    Backwards compatiblity

    What could go wrong?

    If user upgrades to this version, then doesn't have any config/settings.php file and runs php artisan settings:sync it'll use dummy settings in the package, removing user settings in their database.

    This is not a likely scenario of a cautious programmer running any command in production, but it'll be a good security check to have. (I'm not sure how to check for config/settings.php in user code only)

    opened by eduardoarandah 0
  • Show a disabled setting->description field on edit

    Show a disabled setting->description field on edit

    The setting->description describes what the setting does, but we are never able to see the full description in the admin panel. We are able to see a truncated description in the index view of the settings i.e. "Email addresses separated by comma, to b[...]" but when we edit that setting, we don't see the description at all. The description provides useful information on what the setting does and should be shown on the edit page as a disabled field, similar to the setting->name. I made it a textarea instead of text in case the description is overly long.

    opened by ikkebra 1
  • [Feature] Cache settings

    [Feature] Cache settings

    Add support to SettingsServiceProvider.php to cache settings using the Laravel cache. This slightly improves our performance by storing all the settings in whichever cache we use. For high traffic sites this saves a lot of database access.

    enhancement 
    opened by dkwiebe 3
  • [Feature Req] Cache settings

    [Feature Req] Cache settings

    So, the current implementation of the SettingsServiceProvider::boot() method prevents caching of the settings, forcing 2 queries (one to detect the table, one to load settings) on the DB. It's more efficient for larger sites to cache all settings in memcached or redis, instead of querying the DB on every page hit.

    I looked into extending the provider, but that might be a bit messy.

    If you define a static method for it on the Setting model, then using a config value to point at the FQCN. We could then override the Setting class and extend it to allow caching.

    Just some food for thought.

    triage 
    opened by rk 6
Releases(3.0.16)
Owner
Backpack for Laravel
A collection of packages to create custom admin panels in hours, not days.
Backpack for Laravel
User authentication REST API with Laravel (Register, Email verification, Login, Logout, Logged user data, Change password, Reset password)

User Authentication API with Laravel This project is a user authentication REST API application that I developed by using Laravel and MySql. Setup Fir

Yusuf Ziya YILDIRIM 3 Aug 23, 2022
Store your Laravel application settings in an on-disk JSON file

Store your Laravel application settings in an on-disk JSON file. This package provides a simple SettingsRepository class that can be used to store you

Ryan Chandler 24 Nov 16, 2022
A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Ollie Codes 19 Jul 5, 2021
Persistent settings in Laravel

Laravel Settings Persistent, application-wide settings for Laravel. Despite the package name, this package works with Laravel 4, 5, 6, 7 and 8! Common

Andreas Lutro 855 Dec 27, 2022
Per-user settings repository system for Laravel

Laraconfig Per-user settings repository system for Laravel. This package allows users to have settings that can be queried, changed and even updated,

Italo 170 Oct 26, 2022
Store and retrieve settings generally or for model objects in Laravel.

Store and retrieve settings generally or for model objects in Laravel. Documentation You can find the detailed documentation here in Laravel Settings

Pharaonic 7 Dec 19, 2022
Add settings to any Laravel model.

Laravel Property Bag Simple settings for Laravel apps. Easily give multiple resources settings Simple to add additional settings as your app grows Set

Zach Leigh 80 Aug 8, 2022
Simple Arabic Laravel Dashboard , has basic settings and a nice layout . to make it easy for you to create fast dashboard

Simple Arabic Laravel Dashboard ✅ Auto Seo ✅ Optimized Notifications With Images ✅ Smart Alerts ✅ Auto Js Validations ✅ Front End Alert ✅ Nice Image V

Peter Tharwat 254 Dec 19, 2022
Model Settings for your Laravel app

Model Settings for your Laravel app The package requires PHP 7.3+ and follows the FIG standards PSR-1, PSR-2, PSR-4 and PSR-12 to ensure a high level

Lorand Gombos 611 Dec 15, 2022
⚙️Simple key/value typed settings for your Laravel app with synchronized json export

Simple key/value typed settings for your Laravel app Create, store and use key/value settings, typed from numbers over dates to array, cached for quic

elipZis 8 Jan 7, 2023
Strongly typed settings for Laravel, includes built-in encryption and friendly validation.

Strongly Typed Laravel Settings Install composer require bogdankharchenko/typed-laravel-settings Model Setup namespace App\Models\User; use Illuminat

Bogdan Kharchenko 10 Aug 31, 2022
This Laravel Nova settings tool based on env, using nativ nova fields and resources

Nova Settings Description This Laravel Nova settings tool based on env, using nativ nova fields and resources Features Using native Nova resources Ful

Artem Stepanenko 21 Dec 28, 2022
Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Jameson Lopp 28 Dec 19, 2022
Kalibrant - a package that provides a simple way to manage your models settings

Introduction For your laravel 9.x applications, Kalibrant is a package that provides a simple way to manage your models settings. It is a simple way t

Starfolk 3 Jun 18, 2022
Bootstrap Theme Generator inside of a Wordpress-Settings-Page. Includes live compilation of SCSS!

Bootstrap-Theme-Generator Bootstrap Theme Generator enables you to choose which components of Bootstrap you want to load. It also gives you the possib

null 3 Aug 15, 2022
This project uses dflydev/dot-access-data to provide simple output filtering for cli applications.

FilterViaDotAccessData This project uses dflydev/dot-access-data to provide simple output filtering for applications built with annotated-command / Ro

Consolidation 44 Jul 19, 2022
Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Rubik 4 May 12, 2022
Smeify is a Stable Automated Solution for Airtime and Data businesses in Nigeria, this package helps you integrate smeify easily into your laravel application.

Smeify is a Stable Automated Solution for Airtime and Data businesses in Nigeria, this package helps you integrate smeify easily into your laravel application.

Ogundiran Adewale Charles 2 Jul 27, 2022
Easily integrate single-database multi tenant features into your Laravel application

Laravel Tenant Aware Easily integrate single-database multi tenant features into your Laravel application. Installation You can install the package vi

H-FARM Innovation 9 Dec 21, 2022