PHP code example of roboticsexpert / laravel-decimal
1. Go to this page and download the library: Download roboticsexpert/laravel-decimal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
roboticsexpert / laravel-decimal example snippets
composer
$table->unsignedDecimal('your_field', 32, 16);
use Roboticsexpert\LaravelDecimal\DecimalCast;
class YourModel extend Model {
public $cast=[
'your_field' => DecimalCast::class,
];
}
$model=YourModel::first();
$model->your_filed // \Decimal\Decimal "12345.131123123123123"
//add 123 to your field
$model->your_field=$model->your_field->add('123');
//sub 123 from your field
$model->your_field=$model->your_field->sub('123');
// check php-decimal package for other methods you can use!
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.