Torann / laravel-currency

This provides Laravel with currency functions such as currency formatting and conversion using up-to-date exchange rates.
http://lyften.com/projects/laravel-currency
BSD 2-Clause "Simplified" License
392 stars 137 forks source link

Calling Commands from Controller do not work #62

Closed lpeterke closed 6 years ago

lpeterke commented 7 years ago

In one of my controllers I want to call Artisan::call('currency:update') but it does not work. The Exception:

CommandNotFoundException in Application.php line 490: There are no commands defined in the "currency" namespace.

However, in a different part of my application (a Seeder class), Artisan::call('currency:update') works.

So what is causing the crash in the controller?

lpeterke commented 7 years ago

I had to manually add all the console commands from the package to Console/Kerne.php

If this cannot be fixed withing the package, please expand the docs.

BrunoTeixeiraNavila commented 7 years ago

@apocalyarts Can you share how did you do it for a newbie or share the code please? Thanks

lpeterke commented 7 years ago

Make sure to add the classes to the $commands array:

// In App\Console\Kernel
protected $commands = [
    \Torann\Currency\Console\Update::class,
    \Torann\Currency\Console\Cleanup::class,
    \Torann\Currency\Console\Manage::class
];
BrunoTeixeiraNavila commented 7 years ago

@apocalyarts Tks, worked like a charm

veneliniliev commented 7 years ago

https://github.com/Torann/laravel-currency/blob/master/src/CurrencyServiceProvider.php#L18

remove this condition and all will work fine

qeifar commented 7 years ago

@apocalyarts ThankkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkYouuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu 😄 🤣 😆

Torann commented 6 years ago

If you are updating the exchange rate why not just use a cron job? That is how I have my server setup.