定制 freshleafmedia/laravel-money-cast 二次开发

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

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

freshleafmedia/laravel-money-cast

最新稳定版本:1.0.1

Composer 安装命令:

composer require freshleafmedia/laravel-money-cast

包简介

A Laravel attribute cast for Money values

README 文档

README

A Money cast for Laravel models

Overview

This library provides a Laravel Attribute Cast which serialises Money instances into strings suitable for database storage.

Installation

composer require freshleafmedia/laravel-money-cast

Usage

use Freshleafmedia\MoneyCast\MoneyCast;
use Illuminate\Database\Eloquent\Model;

class MyModel extends Model
{
    // ...

    protected $casts = [
        'cost' => MoneyCast::class,
    ];
    
    // ...
}

Saving

$model = new MyModel();
$model->cost = new \Money\Money('100', new \Money\Currency('GBP'));
$model->save(); // 'GBP100' is persisted to the database.

Retrieving

$cost = MyModel::first()->cost; // Money\Money

$cost->getAmount() // '100'
$cost->getCurrency()->getCode() // 'GBP'

Decimal Amounts

Note that due to the way moneyphp/money works amounts are in the smallest unit. For example GBP100 => £1.00, USD100 => $1.00, JPY100 => ¥100, etc.

See the Formatting section of the moneyphp docs for details

Tests

Unit tests can be run via composer test

License

See LICENSE

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固