laravel-backpack / settings Goto Github PK
View Code? Open in Web Editor NEWApplication settings interface for Backpack (for Laravel 6).
Home Page: http://backpackforlaravel.com
License: Other
Application settings interface for Backpack (for Laravel 6).
Home Page: http://backpackforlaravel.com
License: Other
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?
Page not found. 404
Open menu setting: http://localhost:8000/admin/setting
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" }, ...
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
I've tried to upgrade Backpack from 3.2.x to 3.3.x
Clean upgrade without any errors.
-> % 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.
vendor/backpack/settings/src/routes/backpack/settings.php
(seen in 82905b0#diff-07b8faea13131bb615e1a0b610347f0d) manually from CRUD::resource(...)
back to Route::resource(...)
- works ok$defer = true;
in vendor/backpack/settings/src/SettingsServiceProvider.php
- works ok (and probably is the right solution)Used separate auth guards for the admin panel and website.
That I could still update Settings with this addon.
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
.
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 ?
on https://github.com/Laravel-Backpack/Settings/blob/master/src/database/seeds/SettingsTableSeeder.php
on line 51
'field' => '{"name":"value","label":"Value", "title":"Motto value" ,"type":"textarea"}',
must be
'field' => '{"name":"value","label":"Value","type":"textarea"}',
Setting title attribute, if I change "label":"Value" in "label":"My Value" it don't work
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
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.
Hi,
Would it be possible to spawn multiple settings pages with each their own settings database?
The [ +Add Setting] button is not showing up when I go to Settings (admin/setting)
Fresh install of the latest Laravel followed by installing Backpack and backpack-settings
To see the Add Setting button in the index view
The create button is not there.
backpack crud 4.0.23, laravel 6.6.2, php 7.3.11, mariadb 10.3.16
Not saving
I tried to save a setting the setting was not saved
Save the setting
Not saved in the database.
Nothing
Backpack 4.0, Laravel 6.0.3, PHP 7.3.7, MariaDB 10.3.16
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..
In
SettingServiceProvider.php
setupRoutes method
I changed
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');
404 not found if I change default prefix admin route
Also same error in file manager.
As described on title, I can not get the value from my console command class, but it works on Controller class or other places.
PR to fix: #27
Got an alert with DataTable warning: table_id=crudTable Ajax Error
updated to Backpack 3.3
Show my settings table
Followed the link in the alert
Backpack 3.3
Laravel 5.5.21
Php 7.1
Follow the steps to upgrade to CRUD 3.3
Latest version of this package to install (2.0.24)
Some old version was installed (2.0.8)
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.
0.8, 5.5, 7.0, MariaDB 10.1
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.
We should add all texts in language files. Ex. page title
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
Enable package auto-discovery for faster installation on L5.5. Eliminate 2-3 steps out of the installation process with a small composer modif:
https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518
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.
The store and update method in the controller have invalid request type when I try to pass on my UserSettingRequest instead of a SettingRequest.
I'm wondering if there is a way to do what I'm trying to accomplish here!
Laravel 5.7
PHP 7.2.20
Hey
After update i get this message:
Undefined variable: saveAction
when i try to edit setting
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"}
Subject
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?
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));
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?
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?
Setup as instructed, everything is working. I then tried to run FunctionalTests using PHPBrowser (via CodeCeption).
For my settings to be available in all versions of the app.
The settings don't get loaded because Backpack\Settings\SettingsServiceProvider::boot()
specifically excludes loading them when running on the command line.
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.
Settings: 2.1.2
Backpack CRUD: 3.5.10
Laravel: 5.7.16
PHP: 7.2
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?
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?
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.
url: admin/setting
FatalErrorException in SettingCrudController.php line 12:
Class 'Backpack\CRUD\app\Http\Controllers\CrudController' not found
When developing and using, for example, something like php artisan migrate:refresh --seed
the migrations and seeds for settings are not getting migrated again.
Hello) I need to show validation rules when admins type some non correct data, how can I get it and how can I translate it ?
@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.
It does not appear to be compatible with PHP 7.4
I upgraded to PHP 7.4 and then the Settings page does not finish loading and times out.
I downgraded back to PHP 7.3 and it works again.
backpack/crud 4.0.40
laravel v6.15.1
php 7.4.2
MariaDB 10.3.22
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
Use table field
Show table field in update route
Here's the stack trace
[Flare App link redacted]
Nothing. Tried to debug it but can't find anything
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
v7.12.0@c2fff1e9879494a6f853593b3c517dc9922bbb51
4.1.6@cbd4143d3eb8302916012af205565cd3183f274f
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
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.
➜ composer require backpack/settings
➜ php artisan vendor:publish --provider="Backpack\Settings\SettingsServiceProvider"
Publishing complete.
➜ php artisan migrate
Nothing to migrate.
Migrations should be added to my database/migrations
directory and executed
Migrations are not published and there's nothing to migrate
Tried to clear cache, clear config with artisan
Backpack v0.8.2
Laravel v5.5.20
PHP 7.10.1
DB Mysql
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"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.