niclashedam / eloquent-round
此包已被废弃,不再维护。未建议替代包。
Laravel Eloquent 中小数/浮点/双精度数的自动四舍五入
1.3.4
2022-06-22 11:48 UTC
Requires
- php: >=7.3
- illuminate/database: ^5|^6|^7|^8
Requires (Dev)
README
此包可以在 eloquent 模型设置属性时自动将所有给定的小数值四舍五入。当使用 MySQL 数据库时,这尤其有用,因为您可以知道正确的值被写入数据库。
安装
使用 composer 安装
composer require niclashedam/eloquent-round
使用
使用 RoundsDecimals 特性。
use NiclasHedam\EloquentRound\RoundsDecimals;
class Model extends \Illuminate\Database\Eloquent\Model
{
use RoundsDecimals;
public $rounds = [
'decimal' => 2,
'preciseDecimal' => 4,
];
}
$model->decimal = 1.675;
echo $model->decimal; //1.68
贡献
- 分支它!
- 创建您的功能分支:
git checkout -b my-new-feature
- 提交您的更改:
git commit -am '添加一些功能'
- 推送到分支:
git push origin my-new-feature
- 提交 pull request :D
许可证
在 MIT 许可下发布