Search by

imagina / icurrency-module

imagina

This module manages currencies and conversions

Package info

github.com/imagina/imaginacms-icurrency

Type:asgard-module

pkg:composer/imagina/icurrency-module

Statistics

Installs: 579

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.6 2020-02-19 14:36 UTC

This package is auto-updated.

Last update: 2026-09-23 20:29:43 UTC


README

Installation

composer require imagina/icurrency

php artisan module:migrate Icurrency

php artisan db:seed --class=\\Modules\\Icurrency\\Database\\Seeders\\CurrencyTableSeederTableSeeder

Add middleware in acms/app/Http/Kernel.php

  protected $middleware = [
    // ...
      \Modules\Icurrency\Http\Middleware\CurrencyMiddleware::class,
    // ...
  ];

Note: This middleware expects the currency configuration within the object or from the request filter object. Example: api/iquote/v1/products?setting={"currency":"COP"} o api/iquote/v1/products?filter={"currency":"COP"}, 'settings' have higher priority.

Add command for updates TRM in acms/app/Console/Kernel.php

  protected $commands = [
    // ...
      Modules\Icurrency\Console\UpdateCurrencies::class
    // ...
  ];

Add .env your Api Key

Get your api key in currencyconverterapi

Free Forex API Rate Limits
Currency Pairs per Request: 2
Number of Requests per Hour: 100

CURRCONV_APIKEY=apikye

Run the following command the first time after making the migration to synchronize the currencies at the current exchange rate, after this they will be updated automatically with cron job.

php artisan currencies:update

Add command in schedule Laravel in acms/app/Console/Kernel.php

  protected function schedule(Schedule $schedule)
  {
    // ...
    $schedule->command(Modules\Icurrency\Console\UpdateCurrencies::class)->dailyAt('01:00');
    // ...
  }

Default Currencies Available

NAME CODE
United States Dollar USD
Colombian Peso COP
Australian dollar AUD
Mexican Peso MXN
Euro EUR

Use Facade Currency

Add follow line on the class that you need use this Facade:

use Modules\Icurrency\Support\Facades\Currency;

Methods Available

  • Convert a value:

      /* Example */
      Currency::convert(1000): 
  • Convert a value from one currency to another currency:

      /* Example */
      Currency::convertFromTo(1000, 'COP', 'AUD');
  • Get the current currency:

      /* Example */
      Currency::getLocaleCurrency();
  • Set current currency:

      /* Example */
      Currency::setLocaleCurrency('COP');
  • Get array with all current supported:

      /* Example */
      Currency::getSupportedCurrencies();

End Points

Route Base: https://yourhost/api/icurrency/v1/

  • Currencies

  • Attributes

    NAME TYPE NULLABLE TRANSLATABLE
    name String ☐ ☑
    code String ☐ ☐
    symbol_left String ☐ ☐
    symbol_right String ☐ ☐
    decimal_place char ☐ ☐
    value double ☐ ☐
    status tinyInteger ☐ ☐
    default_currency boolean ☐ ☐
    options text ☐ ☐
    • Create.

      • Method: POST

      • Requires Authentication: ☑

      • Routes:

        • /currencies
      • Post params (Example):

        {
           attributes:{
             name: 'name',
             code: 'code',
             symbol_left: 'symbol_left',
             symbol_right: 'symbol_right',
             decimal_place: 'decimal_place',
             value: 'value',
             status: 'status',
             default_currency: 'default_currency',
           }
        }
        
    • Read

      • Method: GET

      • Requires Authentication: ☐

      • Routes:

        • /currencies
        • /currencies/id
      • Filters

        search
        date
        order
    • Update

      • Method: PUT
      • Requires Authentication: ☑
      • Routes:
        • /currencies/id
    • Delete

      • Method: DELETE
      • Requires Authentication: ☑
      • Routes:
        • /currencies/id