ownego/laravel-shopify-currency

使用 Shopify 的货币 CDN 文件实现的货币转换器

1.0.0 2021-12-13 08:15 UTC

This package is auto-updated.

Last update: 2024-09-13 14:18:44 UTC


README

此包是为了通过使用 Shopify 提供的 currencies.js 文件在两种货币之间进行转换而创建的。

安装

  1. 安装包

    composer require ownego/laravel-shopify-currency
    
  2. 可选:添加服务提供者

    'providers' => [
       // ...
       Ownego\LaravelShopifyCurrency\LaravelShopifyCurrencyServiceProvider::class,
    ],
  3. 可选:发布配置

    php artisan vendor:publish --provider=Ownego\LaravelShopifyCurrency\LaravelShopifyCurrencyServiceProvider
    
  4. 可选:添加外观

    'alias' => [
       // ...
       'ShopifyCurrency' => Ownego\LaravelShopifyCurrency\Facades\ShopifyCurrency::class,
    ],

使用方法

  1. 转换
    use Ownego\LaravelShopifyCurrency\Facades\ShopifyCurrency;
    
    $result = ShopifyCurrency::convert(100, 'eur', 'usd');
  2. 获取汇率
    use Ownego\LaravelShopifyCurrency\Facades\ShopifyCurrency;
    
    $result = ShopifyCurrency::rate('eur', 'usd');

命令

如果您想手动从缓存中更新货币,请运行

php artisan shopify-currency:cache