|
@@ -75,6 +75,56 @@ Run the database seeder
|
75
|
75
|
|
76
|
76
|
php artisan migrate:refresh
|
77
|
77
|
|
|
78
|
+## Currency Exchange Rates
|
|
79
|
+
|
|
80
|
+### Overview
|
|
81
|
+
|
|
82
|
+This application offers support for real-time currency exchange rates. This feature is disabled by default. To enable it, you must first register for an API key at [ExchangeRate-API](https://www.exchangerate-api.com/). The application uses this service due to its generous provision of up to 1,500 free API calls per month, which should be enough for development and testing purposes.
|
|
83
|
+
|
|
84
|
+**Disclaimer**: There is no affiliation between this application and ExchangeRate-API.
|
|
85
|
+
|
|
86
|
+Once you have your API key, you can enable the feature by setting the `CURRENCY_API_KEY` environment variable in your `.env` file.
|
|
87
|
+
|
|
88
|
+### Configuration
|
|
89
|
+
|
|
90
|
+Of course, you may use any service you wish to retrieve currency exchange rates. If you decide to use a different service, you can update the `config/services.php` file with your choice:
|
|
91
|
+
|
|
92
|
+```php
|
|
93
|
+'currency_api' => [
|
|
94
|
+ 'key' => env('CURRENCY_API_KEY'),
|
|
95
|
+ 'base_url' => 'https://v6.exchangerate-api.com/v6',
|
|
96
|
+],
|
|
97
|
+```
|
|
98
|
+
|
|
99
|
+Additionally, you may update the following method in the `app/Services/CurrencyService.php` file which is responsible for retrieving the exchange rate:
|
|
100
|
+
|
|
101
|
+```php
|
|
102
|
+public function getExchangeRate($from, $to)
|
|
103
|
+{
|
|
104
|
+ $api_key = config('services.currency_api.key');
|
|
105
|
+ $base_url = config('services.currency_api.base_url');
|
|
106
|
+
|
|
107
|
+ $req_url = "{$base_url}/{$api_key}/pair/{$from}/{$to}";
|
|
108
|
+
|
|
109
|
+ $response = Http::get($req_url);
|
|
110
|
+
|
|
111
|
+ if ($response->successful()) {
|
|
112
|
+ $responseData = $response->json();
|
|
113
|
+ if (isset($responseData['conversion_rate'])) {
|
|
114
|
+ return $responseData['conversion_rate'];
|
|
115
|
+ }
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ return null;
|
|
119
|
+}
|
|
120
|
+```
|
|
121
|
+
|
|
122
|
+### Important Information
|
|
123
|
+
|
|
124
|
+- To use the currency exchange rate feature, you must first obtain an API key from a service provider. This application is configured to use a service that offers a free tier suitable for development and testing purposes.
|
|
125
|
+- Your API key is sensitive information and should be kept secret. Do not commit it to your repository or share it with anyone.
|
|
126
|
+- Note that API rate limits may apply depending on the service you choose. Make sure to review the terms for your chosen service.
|
|
127
|
+
|
78
|
128
|
## Dependencies
|
79
|
129
|
|
80
|
130
|
- [filamentphp/filament](https://github.com/filamentphp/filament) - A collection of beautiful full-stack components
|