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

Error in Middleware and no formatting of default currency #45

Closed matbeard closed 7 years ago

matbeard commented 8 years ago

When I add the Middleware to Kernel.php I get the following error on all pages:

FatalThrowableError in CurrencyMiddleware.php line 29:
Call to a member function get() on null

Also, the default currency (which I have set to GBP) is not formatted. If I use Currency::format(15) the result is simply 15. If I specify the currency: Currency::format(15,'GBP') it is properly formatted as £15.00. Conversion is working.

azrahn commented 8 years ago

Yes I had the same . I had to use Currency::format($amount,Session::get('currency') to get the format working.

golinmarq commented 8 years ago

How do you solve the fatal throwable error?

azrahn commented 8 years ago

did you run the migration?

golinmarq commented 8 years ago

Sure

dakshhmehta commented 8 years ago

I face the same problem, but why isnt it working with helper function currency which is doing same thing? Isn't it?

lyonlim commented 8 years ago

I realised the issue with the exception is because \Illuminate\Session\Middleware\StartSession::class, has not started. In 5.2, this is under $middlewareGroups in Http\Kernel.

Moving \Torann\Currency\Middleware\CurrencyMiddleware::class, to $middlewareGroups fixes this.

DrudgeRajen commented 8 years ago

@lyonlim :+1:

shafaqatrazaa commented 6 years ago

@azrahn where should I add this ?? Currency::format($amount,Session::get('currency')

shafaqatrazaa commented 6 years ago

@lyonlim it didn't worked

shafaqatrazaa commented 6 years ago

Someone please help me in solving this image