-
Notifications
You must be signed in to change notification settings - Fork 78
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
Config::get not working on a Command Extension #23
Comments
Try adding this at the top use Backpack\Settings\app\Models\Setting as Setting; Then this before your code
|
Perfect, I would never get to that, thank you @OwenMelbz |
Ha I only knew this because I started the PR which broke it xD This is a tricky one, coz basically there is an issue that the settings package tries to connect with the database every time the application starts. Including when you run things like This causes issues when there is no database present, e.g if a test suite is running, automatic deployments etc. So a recent PR prevented the settings module from running when run from the command line, which as it happens affects your command. We might need to re-factor that PR again a little, to enable something like @tabacitu you got any ideas for this? |
Damn. I don't have any bright ideas, I'm afraid.
Can't say I like either of those very much, as they're breaking changes... |
I think keeping the native syntax is probably nicest. The benefit of using flat file storage is that it's much more easily source controlled and deployed, however would cause a tiny performance hit. My personal approach would be to do something like use Backpack\Settings;
public function __construct()
{
Settings::init();
parent::__construct();
} Then we can enable users to use it on the CLI if they need by initialising it. This I think is a similar approach to the step where you need to mock a class when running tests, so we just need to initialise it and it will work? I cant see any other way really? |
@OwenMelbz is this really an issue when we check for the table existence? I see there's already a check for that in place - This would probably provide no benefit now, but would be independent from "settings" table name in the future, if there's need to change the name. |
Hey, Yeah it completely matters 😛 You cannot check for a table on a database that does not exist 😄 |
You're right. I should probably go home already, sorry :) |
😂 |
So, to sum it up, this is probably the best answer. Closing the issue. Cheers! |
This is my command extension file:
The idea is to send an email to the email configured.
Outputs
Email:
(null) for some reason..The text was updated successfully, but these errors were encountered: