定制 restuniverse/currency 二次开发

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

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

restuniverse/currency

Composer 安装命令:

composer require restuniverse/currency

包简介

This package provides Laravel functions such as currency formatting and conversion using up-to-date exchange rates.

README 文档

README

Installation

Composer

From the command line run:

$ composer require restuniverse/currency

Laravel's >=5.5 Auto-Discovery

Simply install the package and let Laravel do its magic.

Manual Setup

Once installed you need to register the service provider with the application. Open up config/app.php and find the providers key.

'providers' => [

    \RestUniverse\Currency\CurrencyServiceProvider::class,

]

This package also comes with a facade, which provides an easy way to call the the class. Open up config/app.php and find the aliases key.

'aliases' => [

    'Currency' => \RestUniverse\Currency\Facades\Currency::class,

];

Publish the configurations

Run this on the command line from the root of your project:

php artisan vendor:publish --provider="RestUniverse\Currency\CurrencyServiceProvider" --tag=config

A configuration file will be published to config/currency.php.

Migration

If currencies are going to be stored in the database.

php artisan vendor:publish --provider="RestUniverse\Currency\CurrencyServiceProvider" --tag=migrations

Run this on the command line from the root of your project to generate the table for storing currencies:

$ php artisan migrate

note: Add your API_KEY to the .env file with (REST_UNIVERSE_API_KEY).

Basic usage

The simplest way to use these methods is through the helper function currency() or by using the facade. For the examples below we will use the helper method.

currency($amount, $from = null, $to = null, $format = true)

Arguments:

$amount - The float amount to convert $from - The current currency code of the amount. If not set, the application default will be used (see config/currency.php file). $to - The currency code to convert the amount to. If not set, the user-set currency is used. $format - Should the returned value be formatted.

Usage:

echo currency(12.00);               // Will format the amount using the user selected currency
echo currency(12.00, 'USD', 'EUR'); // Will format the amount from the default currency to EUR

Updating Exchange Rates

Update exchange rates from restuniverse.com. An API key is needed to use Rest Universe. Add yours to the config file.

php artisan currency:hydrate

Security

If you discover any security related issues, please email security@restuniverse.com instead of using the issue tracker.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2022-01-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固