bizmitra/amountinwords 问题修复 & 功能扩展

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

邮箱: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
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固