victoravelar/laravel-dashboard-exchange-rates-tile

允许您显示所选货币及其相对于您选择的基币种的汇率列表。

v0.2.0 2022-10-21 07:12 UTC

This package is auto-updated.

Last update: 2024-09-21 11:16:25 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

允许您显示所选货币及其相对于您选择的基币种的汇率列表。

此小部件可用于 Laravel Dashboard

安装

您可以通过 composer 安装此包。

composer require VictorAvelar/laravel-dashboard-exchange-rates-tile

用法

汇率小部件

根据您的提供商,此小部件将显示配置中列出的符号的最新汇率。

在您的仪表板视图中,您使用 livewire:dashboard-exchange-rates-tile 组件。

<x-dashboard>
    <livewire:exchange-rates-tile position="a1" />
</x-dashboard>
示例

Exchange rates example

汇率转换器

在此小部件上显示您基币种中一定金额转换为配置中的每个符号的转换。

在您的仪表板视图中,您使用 livewire:dashboard-exchange-converter-tile 组件。

<x-dashboard>
    <livewire:exchange-converter-tile position="a1" />
</x-dashboard>
示例

Exchange rates example

获取汇率

app\Console\Kernel.php 中,您应安排运行 Avelar\ExchangeRates\UpdateCurrencyExchangeRatesCommand

// in app/console/Kernel.php

protected function schedule(Schedule $schedule)
{
    // ...
    $schedule->command(Avelar\ExchangeRates\UpdateCurrencyExchangeRatesCommand::class)->everyMinute();
}

自定义视图

php artisan vendor:publish --provider="Avelar\ExchangeRates\ExchangeRatesTileServiceProvider" --tag="dashboard-exchange-rates-views"

配置

// in config/dashboard.php

return [
    // other settings
    'tiles' => [
        // other tiles ...
        'exchange_rates' => [
            /*
            |--------------------------------------------------------------------------
            | Exchange rates provider.
            |--------------------------------------------------------------------------
            |
            | Value for the exchange rates provider you prefer to use, the tile was
            | build using exchangerate.host which is free but it is also fully 
            | compatible with fixer.io which has a freemium model.
            |
            | Accepted values are: "exchangerates.host" and "fixer.io".
            |
            */
            'provider' => 'exchangerate.host',

             /*
            |--------------------------------------------------------------------------
            | Base currency.
            |--------------------------------------------------------------------------
            |
            | The currency you want to use as base for the exchange rates display.
            |
            | Any currency is accepted as base as long as it is supported by your
            | exchange rate provider.
            |
            */
            'base' => 'EUR',
            
            /*
            |--------------------------------------------------------------------------
            | Symbols to track.
            |--------------------------------------------------------------------------
            |
            | An array of exchange rate(s) symbols you wish to track.
            |
            | Example: ['USD', 'JPY', 'MXN']
            |
            */
            'symbols' => ['GBP', 'USD'],
            
            /*
            |--------------------------------------------------------------------------
            | Crypto assets to track.
            |--------------------------------------------------------------------------
            |
            | An array of crypto assets(s) you wish to track.
            |
            | The support for this feature depends on the provider you are using and
            | the crypto exchanges/assets this provider tracks.
            |
            | Currently only exchangerates.host is available as crypto provider and 
            | the list of available assets can be found here:
            | https://api.exchangerate.host/cryptocurrencies
            |
            | Example: ['BTC']
            |
            */
            'crypto' => ['BTC'],

            /*
            |--------------------------------------------------------------------------
            | Fixer.io API key.
            |--------------------------------------------------------------------------
            |
            | When using fixer.io as provider you need to privide a valid API key
            | in order to access the API.
            |
            */
            'api_key' => env('FIXER_API_KEY', ''),
            
            /*
            |--------------------------------------------------------------------------
            | Tile refresh interval (optional).
            |--------------------------------------------------------------------------
            |
            | How often should the dashboard refresh your tile.
            |
            | If none set, it defaults to 60s.
            |
            */
            'refresh_interval_in_seconds' => 60,

            /*
            |--------------------------------------------------------------------------
            | Converter value.
            |--------------------------------------------------------------------------
            |
            | An amount to track against the specified symbols and crypto assets.
            |
            | Example: 500
            | 
            | This will display a list in a similar fashion than the one tracking the 
            | exchange rates, the content will refer to the amount in X currency
            | you will get by converting n amount of the base currency.
            |
            */
            'convert_value' => 500,
        ],
    ],
];

测试

composer test

安全

如果您发现任何与安全相关的问题,请通过电子邮件 deltatuts@gmail.com 联系我们,而不是使用问题跟踪器。

致谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件