1. Go to this page and download the library: Download elegantly/laravel-money 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/ */
elegantly / laravel-money example snippets
return [
'default_currency' => 'USD',
];
Schema::create('invoices', function (Blueprint $table) {
$table->id();
$table->bigInteger('amount'); // Store in cents
$table->string('currency', 3); // ISO currency code
$table->timestamps();
});
use Elegantly\Money\MoneyCast;
/**
* @property ?Money $amount
* @property ?string $currency
**/
class Invoice extends Model {
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'amount' => MoneyCast::class . ':currency'
];
}
}