mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-05 13:34:36 -04:00
Merge pull request #8352 from datasolutionsbz/patch-4
Create 2023_03_10_100629_add_currencies.php
This commit is contained in:
commit
f04aec1fa4
47
database/migrations/2023_03_10_100629_add_currencies.php
Normal file
47
database/migrations/2023_03_10_100629_add_currencies.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Currency;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Model::unguard();
|
||||||
|
|
||||||
|
$currencies = [
|
||||||
|
['id' => 114, 'name' => 'BZ Dollar', 'code' => 'BZD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($currencies as $currency) {
|
||||||
|
$record = Currency::whereCode($currency['code'])->first();
|
||||||
|
if ($record) {
|
||||||
|
$record->name = $currency['name'];
|
||||||
|
$record->symbol = $currency['symbol'];
|
||||||
|
$record->precision = $currency['precision'];
|
||||||
|
$record->thousand_separator = $currency['thousand_separator'];
|
||||||
|
$record->decimal_separator = $currency['decimal_separator'];
|
||||||
|
if (isset($currency['swap_currency_symbol'])) {
|
||||||
|
$record->swap_currency_symbol = $currency['swap_currency_symbol'];
|
||||||
|
}
|
||||||
|
$record->save();
|
||||||
|
} else {
|
||||||
|
Currency::create($currency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user