### Install and Configure Backpack Settings
Source: https://github.com/laravel-backpack/settings/blob/main/README.md
Commands to install the package, publish configuration, run migrations, add menu items, and seed the database.
```bash
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 ""
# For Backpack v5 or v4
php artisan backpack:add-sidebar-content "
Settings"
# [optional] insert some example dummy data to the database
php artisan db:seed --class="Backpack\Settings\database\seeds\SettingsTableSeeder"
```
--------------------------------
### Running Tests
Source: https://github.com/laravel-backpack/settings/blob/main/README.md
Command to execute the test suite for the Laravel Backpack Settings package.
```bash
composer test
```
--------------------------------
### Running Tests
Source: https://github.com/laravel-backpack/settings/blob/main/CONTRIBUTING.md
This command executes the project's tests. Currently, the project lacks working tests, and contributing to this area is highly encouraged.
```bash
$ composer test
```
--------------------------------
### Accessing Settings in Code
Source: https://github.com/laravel-backpack/settings/blob/main/README.md
Demonstrates how to retrieve setting values stored in the database using the `Setting` or `Config` facade.
```php
Setting::get('contact_email')
// or
Config::get('settings.contact_email')
```
--------------------------------
### Settings Database Table Structure
Source: https://github.com/laravel-backpack/settings/blob/main/README.md
Details the columns in the 'settings' table where application settings are stored.
```APIDOC
Settings Table:
- id: Primary key (e.g., 1)
- key: Unique identifier for the setting (e.g., contact_email)
- name: Human-readable name for the setting (e.g., Contact form email address)
- description: Explanation of the setting's purpose (e.g., The email address that all emails go to.)
- value: The actual value of the setting (e.g., admin@laravelbackpack.com)
- field: Backpack CRUD field configuration in JSON format. The "name" of the field must be "value". See https://backpackforlaravel.com/docs/crud-fields#default-field-types for field type configuration.
- active: Boolean flag (1 or 0) indicating if the setting is active.
- created_at: Timestamp of creation.
- updated_at: Timestamp of last update.
```
--------------------------------
### Basic PHP Dump
Source: https://github.com/laravel-backpack/settings/wiki/Something-about-this
A simple PHP snippet demonstrating the use of the dd() function, commonly used for debugging in Laravel applications.
```php
dd('smth');
```
--------------------------------
### Override Backpack 'show_powered_by' Setting
Source: https://github.com/laravel-backpack/settings/blob/main/README.md
This snippet demonstrates how to override the Backpack 'show_powered_by' configuration setting. It involves adding a method to `AppServiceProvider` to read the setting from the database and apply it to the application's configuration. This requires a database entry for the 'show_powered_by' setting.
```php
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);
}
}
```
--------------------------------
### Database Entry for 'show_powered_by' Setting
Source: https://github.com/laravel-backpack/settings/blob/main/README.md
This shows the structure of a database entry required to override the 'show_powered_by' setting in Laravel Backpack. The 'field' column must be a JSON string, and the 'name' key within that JSON must be 'value'.
```APIDOC
Database Table: settings
| 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 |
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.