corealg / helper
该包提供了一些常用的辅助函数,这些函数在几乎每个项目中都需要定期使用。
v1.0.0
2021-09-27 10:45 UTC
Requires
- php: >=7.0
- ntwindia/ntwindia: ^1.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.5
README
该包提供了一些常用的辅助函数,这些函数在几乎每个项目中都需要定期使用。
有用的辅助函数将不断添加
安装
使用composer安装此包。
composer require corealg/helper
品牌化
在config/app.php的别名部分下设置自定义别名
将MyHelper
替换为您的品牌
'MyHelper' => CoreAlg\Helper\Helper::class,
用法
获取分页摘要
<?php echo MyHelper::paginationSummary(100, 10, 1); // Output: Showing 1 to 10 of 100 records
数字转换为文字
<?php echo MyHelper::number2word(100); // Output: One Hundred Taka Only.
格式化金额
<?php echo MyHelper::formatAmount(10000, 2, '.', ','); // Output: 10,000.00
控制您应用程序金额格式的功能
<?php // set amount_format into session variable under `core_helper` key (you can do this once after login) session()->put('core_helper', [ 'amount_format' => [ // you can set this value from database as well 'decimals' => 3, 'decimal_separator' => '.', 'thousands_separator' => ',' ] ]); $order = \App\Models\Order::find(1); echo MyHelper::formatAmount($order->amount); // Output: 10,000.000
格式化日期
<?php echo MyHelper::formatDate("2021-09-27", "d M, Y"); // Output: 27 Sep, 2021
控制您应用程序日期格式的功能
<?php // set data_format into session variable under `core_helper` key (you can do this once after login) session()->put('core_helper', [ 'date_format' => 'd M, Y @ h:i:s A (P)' // you can set this value from database as well ]); $user = \App\Models\User::find(1); echo MyHelper::formatDate($user->created_at); // Output: 27 Sep, 2021 @ 03:25:10 PM (+06:00)
测试
composer test
贡献
欢迎拉取请求。对于重大更改,请先创建一个问题来讨论您想要进行的更改。
请确保适当更新测试。
作者
许可
版权 (c) 2021 CoreAlg