mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Classes\Modules\Countries\Services\FetchesCountry;
|
|
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyObject;
|
|
use App\Classes\Modules\Currencies\Services\CreatesCurrency;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class CurrenciesTableSeeder extends Seeder
|
|
{
|
|
/** @var FetchesCountry */
|
|
private $fetchesCountry;
|
|
|
|
/** @var CreatesCurrency */
|
|
private $createsCurrency;
|
|
|
|
/**
|
|
* CurrenciesTableSeeder constructor.
|
|
* @param FetchesCountry $fetchesCountry
|
|
* @param CreatesCurrency $createsCurrency
|
|
*/
|
|
public function __construct(FetchesCountry $fetchesCountry, CreatesCurrency $createsCurrency)
|
|
{
|
|
$this->fetchesCountry = $fetchesCountry;
|
|
$this->createsCurrency = $createsCurrency;
|
|
}
|
|
|
|
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
*/
|
|
public function run()
|
|
{
|
|
|
|
foreach (['my', 'cn'] as $code) {
|
|
$country = country($code);
|
|
$object = new CurrencyObject($country->getCurrency()['iso_4217_name'],
|
|
$code === 'cn' ? 'RMB' : $country->getCurrency()['iso_4217_code'],
|
|
$code === 'my' ? 'RM' : ( $code === 'cn' ? '¥' : '' ));
|
|
|
|
$this->createsCurrency->execute($this->fetchesCountry->execute(['name' => $country->getName()]), $object);
|
|
}
|
|
|
|
}
|
|
}
|