Giter Site home page Giter Site logo

settings's Introduction

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
# 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"

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:

  • 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. The "name" of the field is mandatory to be "value") - see the field types and their configuration code on 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

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 setting in /config/backpack/ui.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

NOTE: The field column should be a JSON string. The name key in the JSON string should be value. Using any other key will not work.

  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);
    +   }
    }

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.

settings's People

Contributors

adriallongarriu avatar adriandmitroca avatar deltoss avatar dependabot-preview[bot] avatar eduardoarandah avatar ghitu avatar hafijul233 avatar karandatwani92 avatar mauxtin avatar oliverziegler avatar parabellumkoval avatar paul-crashley avatar phouvanhkcsv avatar promatik avatar pxpm avatar robbfountain avatar sang-lu avatar selcukcukur avatar shamarkellman avatar shiroamada avatar shuxx avatar stylecibot avatar tabacitu avatar tolgap avatar tomsb avatar twmbx avatar urlportal avatar vasiliy-bondarenko avatar vonsogt avatar xayer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

settings's Issues

[Feature req] Define fields in config file (PHP)

@eduardoarandah was saying on Gitter:

Settings manager should default from a regular config/settings file
Because adding settings to a production app is pain
No only settings values, also fields definitions.
Right now, code goes to repository and settings fields definitions don’t because they live in database.
Defaulting from regular config file also gives us the power of .env file, caching, etc

At first I didn’t agree, but now I think he may be onto something. It would be A LOT easier to define each Setting in PHP, not JSON in the db. Then Setting::get() would get the value from the DB, if it exists, otherwise it would fall back to the default in the configuration file.

Override existing configurations

just like its mentioned on the readme.. I tried the skin config but nothing happens.

ive added the AppServiceProvider code as well.. but nothing happens and when i try to call the Setting facade directly to \config\backpack.base, it throws an error.

how can we set config values directly from the db?

Add Setting button is missing

Bug report

The [ +Add Setting] button is not showing up when I go to Settings (admin/setting)

What I did:

Fresh install of the latest Laravel followed by installing Backpack and backpack-settings

What I expected to happen:

To see the Add Setting button in the index view

What happened:

The create button is not there.

What I've already tried to fix it:

Backpack, Laravel, PHP, DB version:

backpack crud 4.0.23, laravel 6.6.2, php 7.3.11, mariadb 10.3.16

403 Unauthorized (?!)

I'm using the last version of Laravel (5.5.*) and the version ^2.0 for Settings in my composer.json, I just used these three commands, all works fine (publishing, seeding, migrate...) except one thing, when I try to update one of the default seeded settings, I get a 403 error.

$ php artisan vendor:publish --provider="Backpack\Settings\SettingsServiceProvider"
$ php artisan migrate
$ php artisan db:seed --class="Backpack\Settings\database\seeds\SettingsTableSeeder"

Change default admin route prefix issue

Bug report

In

SettingServiceProvider.php
setupRoutes method

I changed

What I did:

Route::group(['prefix' => config('backpack.base.route_prefix', 'admin'), 'middleware' => ['web', 'admin']], function () { // Settings Route::resource('setting', 'SettingCrudController'); });
Also in

SetingCrudController.php line 18
$this->crud->setRoute(config('backpack.base.route_prefix', 'admin').'/setting');

What happened:

404 not found if I change default prefix admin route
Also same error in file manager.

Using config() inside Artisan

I read on here that it's not possible to use by default the Config::get('setting here') command with Artisan, so inside my Command Class, I've done the following:

use Backpack\Settings;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct() {
    Settings::init();
    parent::__construct();
};
public function handle() {
    $this->info(Config::get('settings.program_status'));
}

But I'm getting this error thrown inside the console:

 [Symfony\Component\Debug\Exception\FatalThrowableError]  
  Class 'Backpack\Settings' not found     

How can I go about fixing this?

Number Field attributes problem

Hey,

I have a problem with the number field.
If I try to add attributes for the step or min / max number like this:
{"name":"value","label":"Value", "title":"Zoom Stufe" ,"type":"number", "attributes":{"min":"10", "max":"20"}}
And try to edit the settings for that it throws the error:
Cannot use object of type stdClass as array

If I change the json_decode parameter in the SettingCrudController to true like this: $this->crud->addField((array) json_decode($this->data['entry']->field), true); it works, but I'm not quite sure if it is a good solution or if the problem is, that my json was wrong... Any suggestions?

Error

url: admin/setting

FatalErrorException in SettingCrudController.php line 12:
Class 'Backpack\CRUD\app\Http\Controllers\CrudController' not found

No data when I'm trying to access from console command.

Hello!
Thank you for the great project but apparently, I've found the bug:

I'm trying to create console command and code such as

echo Config::get('settings.contact_email');

Returns empty string.
But if I'm trying to access to the same code from frontend it's all working perfect.
Am I doings something wrong or it's the bug?

Sincerely, Dmitry

Laravel Setting is not working (not saving)

Bug report

Not saving

What I did:

I tried to save a setting the setting was not saved

What I expected to happen:

Save the setting

What happened:

Not saved in the database.

What I've already tried to fix it:

Nothing

Backpack, Laravel, PHP, DB version:

Backpack 4.0, Laravel 6.0.3, PHP 7.3.7, MariaDB 10.3.16

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:
mongodb/laravel-mongodb#888

Doesn't follow route_prefix changes in base config file

If one wishes to use a different route_prefix to 'admin' this package (& others) break uniformity since they are hard coded to make use of the 'admin' prefix.

This can be improved by causing them to use the config value of a published config file, & defaulting to 'admin' if there isn't a config value set.

I'm working on this.
Will be done in 1 day.

Ambiguous resolution of settings seeder

After

php artisan vendor:publish --provider="Backpack\Settings\SettingsServiceProvider"

I am getting this error in composer.

Warning: Ambiguous class resolution, "Backpack\Settings\database\seeds\SettingsTableSeeder" was found in both "/home/gotre/Projects/backpackgenerator/demo/vendor/backpack/settings/src/database/seeds/SettingsTableSeeder.php" and "/home/gotre/Projects/backpackgenerator/demo/database/seeds/SettingsTableSeeder.php", the first will be used.

What about removing the namespace in the seeder published so there is no conflict ?

undefined index name

Every time i install this and click edit on a setting that has nothing in the field column i get this error

in Fields.php line 28 at HandleExceptions->handleError('8', 'Undefined index: name', '/Users/crameep/Projects/oneocd/vendor/backpack/crud/src/PanelTraits/Fields.php', '28', array('field' => array(), 'form' => 'both', 'complete_field_array' => array())) in Fields.php line 28 at CrudPanel->addField(array()) in SettingCrudController.php line 67 at SettingCrudController->edit('14') at call_user_func_array(array(object(SettingCrudController), 'edit'), array('setting' => '14')) in Controller.php line 80 at Controller->callAction('edit', array('setting' => '14')) in ControllerDispatcher.php line 146 at ControllerDispatcher->call(object(SettingCrudController), object(Route), 'edit') in ControllerDispatcher.php line 94 at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96 at ControllerDispatcher->callWithinStack(object(SettingCrudController), object(Route), object(Request), 'edit') in ControllerDispatcher.php line 54 at ControllerDispatcher->dispatch(object(Route), object(Request), 'Backpack\Settings\app\Http\Controllers\SettingCrudController', 'edit') in Route.php line 174 at Route->runController(object(Request)) in Route.php line 140 at Route->run(object(Request)) in Router.php line 724 at Router->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Admin.php line 29 at Admin->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Admin), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64 at VerifyCsrfToken->handle(object(Request), object(Closure)) at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62 at StartSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Router.php line 726 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699 at Router->dispatchToRoute(object(Request)) in Router.php line 675 at Router->dispatch(object(Request)) in Kernel.php line 246 at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Kernel.php line 132 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99 at Kernel->handle(object(Request)) in index.php line 53 at require('/Users/crameep/Projects/oneocd/public/index.php') in server.php line 106

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

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.

extending SettingCrudController

Bug report

What I did:

Extend SettingCrudController and implementing my own Setting Store and Update request as UserSettingRequest. I'm trying to implement a set of rules for my UserSettingController.

What happened:

The store and update method in the controller have invalid request type when I try to pass on my UserSettingRequest instead of a SettingRequest.

What Should I Do:

I'm wondering if there is a way to do what I'm trying to accomplish here!

Backpack, Laravel, PHP, DB version:

Laravel 5.7
PHP 7.2.20

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?

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

Class 'CRUD' not found during package:discover

Bug report

What I did:

I've tried to upgrade Backpack from 3.2.x to 3.3.x

What I expected to happen:

Clean upgrade without any errors.

What happened:

-> % composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 0 removals
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In settings.php line 18:

  Class 'CRUD' not found

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

This is probably caused by package autodiscovery - after forcing the changes back (next step) I've seen that the autodiscovery order is incorrect (settings are loaded before base and crud):

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
...
Discovered Package: backpack/settings
...
Discovered Package: backpack/base
Discovered Package: backpack/crud
Package manifest generated successfully.

What I've already tried to fix it:

  • Reverted a change in vendor/backpack/settings/src/routes/backpack/settings.php (seen in 82905b0#diff-07b8faea13131bb615e1a0b610347f0d) manually from CRUD::resource(...) back to Route::resource(...) - works ok
  • set $defer = true; in vendor/backpack/settings/src/SettingsServiceProvider.php - works ok (and probably is the right solution)

Backpack, Laravel, PHP, DB version:

  • PHP 7.1.4
  • laravel/framework v5.5.22
  • backpack/base 0.8.2
  • backpack/crud 3.3.1
  • backpack/settings 2.0.25

Add / Remove Setting

Hi,

I just added Settings Package to my BackPack but as far as I can see I cannot add a setting or remove one via the Dashboard... How to?

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.

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

Nothing to publish for tag [] and Table 'xxxxxx.settings' doesn't exist

Hey,

I'm not sure what the ultimate issue is, but I can tell you what happened and what I did to fix it.

I am running Laravel 5.3 and tried to add backpack/settings. I followed the steps in README and it kept blowing up when I tried to execute the line:
php artisan db:seed --class="Backpack\Settings\database\seeds\SettingsTableSeeder"
I would get the error:

 [Illuminate\Database\QueryException]                                                                                                     
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xxxxxx.settings' doesn't exist (SQL: insert into `settings` (`key`, `na  
  me`, `description`, `value`, `field`, `active`) values (contact_email, Contact form email address, The email address that all emails fr  
  om the contact form will go to., [email protected], {"name":"value","label":"Value","type":"email"}, 1))      

Yes, I did all the step in order AND added Backpack\Settings\SettingsServiceProvider::class, to my config/app.php file.

For the life of me I couldn't tell why the command php artisan migrate was not creating the table. I tried all kinds of other commands to clear the cache (in case that was the problem):
php artisan config:clear
php artisan cache:clear

Finally, I looked at the Laravel 5.3 documentation for Package Development : Package Migrations
https://laravel.com/docs/5.3/packages#migrations

I added the following like to this file at line 28: https://github.com/Laravel-Backpack/Settings/blob/master/src/SettingsServiceProvider.php#L28

$this->loadMigrationsFrom(__DIR__.'/database/migrations');

The I re-ran the following commands and it worked:
php artisan vendor:publish --provider="Backpack\Settings\SettingsServiceProvider"
php artisan migrate
php artisan db:seed --class="Backpack\Settings\database\seeds\SettingsTableSeeder"

Hope that helps! Also, hope someone knows what went wrong. Was it a Laravel 5.3 thing?

Thanks,
@BinaryBlock

When give the field attributes as json object, View return error.

Hi,

I try to give attributes value to the field however the views get error.

This is my value in seeder.

[
	        'key'           => 'company_address',
	        'name'          => 'Company Address',
	        'description'   => 'The company address',
	        'value'         => "99/99 Prachautid 99 Prachautid Rd\nTungkru Tungkru Bangkok 10140",
	        'field'         => '{"name":"Setting","label":"Value","type":"textarea", "attributes" : { "rows" : "5" } }',
	        'active'        => 1,
        ]

I try to set attribute rows for the textarea however when it go to view it has the following errors.

Cannot use object of type stdClass as array 
(View: /Users/mike/projects/aluminum/vendor/backpack/crud/src/resources/views/inc/field_wrapper_attributes.blade.php) 
(View: /Users/mike/projects/aluminum/vendor/backpack/crud/src/resources/views/inc/field_wrapper_attributes.blade.php) 
(View: /Users/mike/projects/aluminum/vendor/backpack/crud/src/resources/views/inc/field_wrapper_attributes.blade.php) 
(View: /Users/mike/projects/aluminum/vendor/backpack/crud/src/resources/views/inc/field_wrapper_attributes.blade.php) 
(View: /Users/mike/projects/aluminum/vendor/backpack/crud/src/resources/views/inc/field_wrapper_attributes.blade.php)

I believe it is because of json_decode require assoc parameter = true since it does not decode nested object as an associated array.

I found this in SettingCrudController line 75.

$this->crud->addField((array) json_decode($this->data['entry']->field));

Migrations not published in a Laravel 5.5 app

Bug report

What I did:

➜ composer require backpack/settings
➜ php artisan vendor:publish --provider="Backpack\Settings\SettingsServiceProvider"
Publishing complete.
➜ php artisan migrate
Nothing to migrate.

What I expected to happen:

Migrations should be added to my database/migrations directory and executed

What happened:

Migrations are not published and there's nothing to migrate

What I've already tried to fix it:

Tried to clear cache, clear config with artisan

Backpack, Laravel, PHP, DB version:

Backpack v0.8.2
Laravel v5.5.20
PHP 7.10.1
DB Mysql

Button title

After install the "save" buttons have all changed to backpack::crud.save_action_save_and_back
Uploading Screen Shot 2017-03-09 at 6.48.48 PM.png…

PHP 7.4 compatibility

Bug report

It does not appear to be compatible with PHP 7.4

What I did:

I upgraded to PHP 7.4 and then the Settings page does not finish loading and times out.

What I've already tried to fix it:

I downgraded back to PHP 7.3 and it works again.

Backpack, Laravel, PHP, DB version:

backpack/crud 4.0.40
laravel v6.15.1
php 7.4.2
MariaDB 10.3.22

Add tab Field

Is there any way to add a tab field? or a way to edit the views of the settings page?

In a admin where you have multiple configs gets a bit messy listing all in the same page, so it is good to organize it better.

Thanks.

Why would an error?

run: php artisan vendor:publish --provider="Backpack\Settings\SettingsServiceProvider"

[League\Flysystem\FileNotFoundException]
File not found at path: 015_08_04_131614_create_settings_table.php

How to use select or "page_or_link"

Hi, i need store in settings select, where i can select some model, i try use page_or_link
but have an error

ErrorException in Fields.php line 28:
Undefined index: name

my json
{"name":"value","label":"Name" ,"type":"page_or_link", "page_model":"App\Models\Event"}

[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.

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

Error 404 after upgrade to 3.3

Bug report

Page not found. 404

What I did:

Open menu setting: http://localhost:8000/admin/setting

Backpack, Laravel, PHP, DB version:

3.3, 5.5, 7.0, MySQL [10.1.28-MariaDB]

I notice that my vendo/backpack/settings/composer.json is:
... "require": { "illuminate/support": "~5.1", "php" : ">=5.3.0", "backpack/crud": "^3.0.6" }, ...

[Bug] Doesn't work with non-default guard

Bug report

What I did:

Used separate auth guards for the admin panel and website.

What I expected to happen:

That I could still update Settings with this addon.

What happened:

I got a "403 Forbidden" error when trying to update a setting. That's because the authorize method in src/app/Http/Requests/SettingRequest.php only checks the default guard. It should check for the guard that is specified in config/backpack/base.php.

What I've already tried to fix it:

Backpack, Laravel, PHP, DB version:

Using table field cause ViewException in latest version (Probably have something to do with Backpack 4.1)

Bug report

What I did:

Use table field

What I expected to happen:

Show table field in update route

What happened:

Here's the stack trace
[Flare App link redacted]

What I've already tried to fix it:

Nothing. Tried to debug it but can't find anything

Backpack, Laravel, PHP, DB version:

PHP VERSION:

PHP 7.3.12 (cli) (built: Nov 19 2019 13:58:02) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies

LARAVEL VERSION:

v7.12.0@c2fff1e9879494a6f853593b3c517dc9922bbb51

BACKPACK VERSION:

4.1.6@cbd4143d3eb8302916012af205565cd3183f274f

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.