Seeds
This commit is contained in:
38
db/seeds/Currencies.php
Normal file
38
db/seeds/Currencies.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
|
||||
use Phinx\Seed\AbstractSeed;
|
||||
|
||||
class Currencies extends AbstractSeed
|
||||
{
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
$data = [
|
||||
[
|
||||
'code' => 'CLP',
|
||||
'name' => 'Peso Chileno'
|
||||
],
|
||||
[
|
||||
'code' => 'CLF',
|
||||
'name' => 'Unidad de Fomento'
|
||||
],
|
||||
[
|
||||
'code' => 'USD',
|
||||
'name' => 'US Dollar'
|
||||
],
|
||||
[
|
||||
'code' => 'BTC',
|
||||
'name' => 'Bitcoin'
|
||||
]
|
||||
];
|
||||
$this->table('currencies')->insert($data)->saveData();
|
||||
}
|
||||
}
|
45
db/seeds/Sources.php
Normal file
45
db/seeds/Sources.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user