Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
deepslam opened this issue May 31, 2017 · 5 comments
Closed

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

deepslam opened this issue May 31, 2017 · 5 comments

Comments

@deepslam
Copy link

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

@tabacitu
Copy link
Member

tabacitu commented Jun 8, 2017

Hi @deepslam ,

How about if you change the order of your service providers in your config/app.php?

First Backpack\Settings\SettingsServiceProvider::class,
then Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class

Does this fix it for you?

@moustacherepublic
Copy link

Hi there,

I met the same issue when using Laravel queue.
The supervisord calls the 'php artisan' command actually which would fail to fulfill the condition in class \Backpack\Settings\SettingsServiceProvider :

if (!\App::runningInConsole() && count(Schema::getColumnListing('settings'))) {
...

Could you please fix this issue ?

Thanks,
Skyler

@tabacitu
Copy link
Member

Hi @moustacherepublic ,

Unfortunately, there's a reason for !\App::runningInConsole() to be there: #19

A temporary solution for you would be to use the model inside your console commands, to get the info. So:

\Backpack\Settings\app\Models\Setting::where('key', 'settings.contact_email')->first()->value

should be the same as

Config::get('settings.contact_email')

This is probably the way we'll pluck the settings in the future anyway, using a setting() helper, to prevent this conflict.

@futdev
Copy link

futdev commented Oct 28, 2017

Any update for support on this?

@tabacitu
Copy link
Member

@InkedCurtis just created a PR that provides support for this - #70

Will probably be merged later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants