An interface for the administrator to easily change application settings. Uses Laravel Backpack. Works on Laravel 5.2 to Laravel 8.
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.
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
# For Backpack v6
php artisan backpack:add-menu-content "<x-backpack::menu-item title='Settings' icon='la la-cog' :link=\"backpack_url('setting')\" />"
# For Backpack v5 or v4
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"
Add it to the menu or access it by its route: application/admin/setting
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')
Settings are stored in the database in the "settings" table. Its columns are:
- id (ex: 1)
- key (ex: contact_email)
- name (ex: Contact form email address)
- description (ex: The email address that all emails go to.)
- value (ex: [email protected])
- field (Backpack CRUD field configuration in JSON format. https://backpackforlaravel.com/docs/crud-fields#default-field-types)
- active (1 or 0)
- created_at
- updated_at
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
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
setting in /config/backpack/ui.php
.
-
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 -
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.show_powered_by')) { + $config['backpack.ui.show_powered_by'] = config('settings.show_powered_by') == '1'; + } + config($config); + } }
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING for details.
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;
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.
Backpack is free for non-commercial use and 69 EUR/project for commercial use. Please see License File and backpackforlaravel.com for more information.
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.