edit this page Get Started
From the command line run:
$ composer require torann/currency
Once installed you need to register the service provider with the application. Open up
config/app.php and find the
'providers' => [ \Torann\Currency\CurrencyServiceProvider::class, ]
This package also comes with a facade, which provides an easy way to call the the class. Open up `config/app.php`` and find the aliases key.
'aliases' => [ 'Currency' => \Torann\Currency\Facades\Currency::class, ];
Publish the configurations
Run this on the command line from the root of your project:
php artisan vendor:publish --provider="Torann\Currency\CurrencyServiceProvider" --tag=config
A configuration file will be publish to
If currencies are going to be stored in the database. Run migrate to setup the database table [see Storage Drivers].
php artisan vendor:publish --provider="Torann\Currency\CurrencyServiceProvider" --tag=migrations
Run this on the command line from the root of your project to generate the table for storing currencies:
$ php artisan migrate
The package comes with a set of preset currencies. To add them use the artisan manage command.
Once installed you need to append the middleware class within the Http kernel. This allows visitors to change the viewed currency using the query parameter
app/Http/Kernel.php and find the
protected $middleware = [ \Torann\Currency\Middleware\CurrencyMiddleware::class, ]
Note: The currency middleware uses the session to store the user selected currency, because of this the middleware will need to be added somewhere after