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
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-20