定制 bizmitra/amountinwords 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

bizmitra/amountinwords

最新稳定版本:1.1.2

Composer 安装命令:

composer require bizmitra/amountinwords

包简介

A package to convert amount into words

README 文档

README

A simple Laravel package to convert numeric amounts into their equivalent words.

Installation

You can install the package via Composer. Run the following command in your Laravel project's root directory:

composer require bizmitra/amountinwords

Usage
Step 1: Service Provider Registration
Laravel should automatically detect the service provider. However, if you want to manually register it, add the following line to the providers array in your config/app.php file:

'providers' => [
    // Other Service Providers

    Bizmitra\Amountinwords\AmountinwordsServiceProvider::class,
],


Step 2: Using the Package
You can use the PrintAmountInWords class in your controllers or anywhere in your Laravel application. Here’s an example:

Example Controller
Create a new controller using the following command:

php artisan make:controller AmountController


Then, use the following code in your AmountController.php:

<?php

namespace App\Http\Controllers;

use Bizmitra\Amountinwords\PrintAmountInWords;

class AmountController extends Controller
{
    protected $amountInWords;

    public function __construct(PrintAmountInWords $amountInWords)
    {
        $this->amountInWords = $amountInWords;
    }

    public function index()
    {
        $amount = 12345; // Example amount
        $words = $this->amountInWords->displayWords($amount);

        return response()->json([
            'amount' => $amount,
            'in_words' => $words,
        ]);
    }
}
Step 3: Create a Route
You can create a route to access the controller in your routes/web.php (or routes/api.php) file:

use App\Http\Controllers\AmountController;

Route::get('/amount-in-words', [AmountController::class, 'index']);

Usage
   $amount = 4500.00; // Example amount
    // Call the correct method to convert amount to words with currency names
    $words = $this->amountInWords->amountToWords($amount, 'USD', 'cents');

    return response()->json([
        'amount' => $amount,
        'in_words' => $words,

Step 4: Accessing the Functionality
Now, when you access the /amount-in-words route in your browser or through an API client like Postman, you should get a JSON response with the amount in words:

Step 5: Testing the Functionality
Make sure to test your functionality by accessing the route you created and verifying that it returns the correct output.

License
This package is licensed under the MIT License.

Author
Bizmitra ERP
Mahendrasinh Rana & Vishal
Email: mkr@bizmitra.io

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-20