46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
|
|
use Phinx\Seed\AbstractSeed;
|
|
|
|
class Sources extends AbstractSeed
|
|
{
|
|
public function getDependencies() {
|
|
return [
|
|
'Currencies'
|
|
];
|
|
}
|
|
/**
|
|
* Run Method.
|
|
*
|
|
* Write your database seeder using this method.
|
|
*
|
|
* More information on writing seeders is available here:
|
|
* https://book.cakephp.org/phinx/0/en/seeding.html
|
|
*/
|
|
public function run()
|
|
{
|
|
$id = $this->query("SELECT id FROM currencies WHERE code = 'USD'")->fetchAll(\PDO::FETCH_ASSOC);
|
|
$data = [
|
|
[
|
|
'currency_id' => $id[0]['id'],
|
|
'url' => 'https://mindicador.cl/api/dolar/{year}',
|
|
'frecuency' => '1 DAY'
|
|
]
|
|
];
|
|
$id = $this->query("SELECT id FROM currencies WHERE code = 'CLF'")->fetchAll(\PDO::FETCH_ASSOC);
|
|
$data []= [
|
|
'currency_id' => $id[0]['id'],
|
|
'url' => 'https://mindicador.cl/api/uf/{year}',
|
|
'frecuency' => '1 DAY'
|
|
];
|
|
$id = $this->query("SELECT id FROM currencies WHERE code = 'BTC'")->fetchAll(\PDO::FETCH_ASSOC);
|
|
$data []= [
|
|
'currency_id' => $id[0]['id'],
|
|
'url' => 'https://mindicador.cl/api/bitcoin/{year}',
|
|
'frecuency' => '1 DAY'
|
|
];
|
|
$this->table('sources')->insert($data)->saveData();
|
|
}
|
|
}
|