khetamhamdy/currency-exchange 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

khetamhamdy/currency-exchange

Composer 安装命令:

composer require khetamhamdy/currency-exchange

包简介

A Laravel package for currency exchange and transaction management.

README 文档

README

Introduction

The Currency Exchange package is an open-source PHP library for Laravel that simplifies managing currency exchange operations and transactions. If your application involves working with currencies or financial transactions between currencies, this package provides an efficient solution.

This package is dedicated to my late father, and I hope it helps improve the software development experience.

Features

  • Manage currencies: Add, update, delete, and view currencies.
  • Manage exchange transactions: Add, update, view exchange transactions.
  • Flexible API for currency and transaction data in JSON format.
  • Easy to use and works seamlessly with Laravel 9.0+.

Installation

1. Install via Composer

Install the package in your Laravel application by running the following command in your project directory:

composer require khetamhamdy/currency-exchange

2. Add the Service Provider (if needed)

If you're not using Laravel's package auto-discovery feature, add the service provider manually in the config/app.php file under the providers array:

'providers' => [
    // Other providers...
    KhetamHamdy\CurrencyExchange\Providers\CurrencyExchangeServiceProvider::class,
],

3. Run Migrations

To create the necessary database tables, execute the following command:

php artisan migrate

This will run the migrations provided by the package to set up the required database schema.

Usage

1. Currency Management

Display All Currencies:

use KhetamHamdy\CurrencyExchange\Services\CurrencyService;

$currencyService = app('currency.service');
$currencies = $currencyService->getAllCurrencies();

Add a New Currency:

$currencyService->addCurrency([
    'name' => 'US Dollar',
    'code' => 'USD',
]);

Update a Currency:

$currencyService->updateCurrency($id, [
    'name' => 'Euro',
    'code' => 'EUR',
]);

Delete a Currency:

$currencyService->deleteCurrency($id);

2. Transaction Management

Display All Transactions:

use KhetamHamdy\CurrencyExchange\Services\ExchangeTransactionService;

$exchangeService = app('exchange.service');
$transactions = $exchangeService->listTransactions();

Add a New Transaction:

$exchangeService->createTransaction([
    'from' => 1, // Original currency ID
    'to' => 2,   // Target currency ID
    'rate' => 1.2,
    'date' => now(),
]);

Update a Transaction:

$exchangeService->updateTransaction($id, [
    'from' => 1,
    'to' => 2,
    'rate' => 1.3,
    'date' => now(),
]);

Notes

  • Ensure your application meets the package requirements, including Laravel version 9.0 or higher.
  • Remember to run php artisan migrate after installing the package to set up the database tables.

License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-05