|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Containers\Country\Data\Seeders; |
|
4
|
|
|
|
|
5
|
|
|
use App\Port\Seeder\Abstracts\Seeder; |
|
6
|
|
|
use Webpatser\Countries\CountriesFacade as Countries; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class CountriesSeeder |
|
10
|
|
|
* |
|
11
|
|
|
* @author Mahmoud Zalt <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
class CountriesSeeder extends Seeder |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Run the database seeds. |
|
18
|
|
|
* |
|
19
|
|
|
* @return void |
|
20
|
|
|
*/ |
|
21
|
|
|
public function run() |
|
22
|
|
|
{ |
|
23
|
|
|
|
|
24
|
|
|
//Empty the countries table |
|
25
|
|
|
\DB::table(\Config::get('countries.table_name'))->delete(); |
|
26
|
|
|
|
|
27
|
|
|
//Get all of the countries |
|
28
|
|
|
$countries = Countries::getList(); |
|
29
|
|
|
foreach ($countries as $countryId => $country) { |
|
30
|
|
|
\DB::table(\Config::get('countries.table_name'))->insert(array( |
|
31
|
|
|
'id' => $countryId, |
|
32
|
|
|
'capital' => ((isset($country['capital'])) ? $country['capital'] : null), |
|
33
|
|
|
'citizenship' => ((isset($country['citizenship'])) ? $country['citizenship'] : null), |
|
34
|
|
|
'country_code' => $country['country-code'], |
|
35
|
|
|
'currency' => ((isset($country['currency'])) ? $country['currency'] : null), |
|
36
|
|
|
'currency_code' => ((isset($country['currency_code'])) ? $country['currency_code'] : null), |
|
37
|
|
|
'currency_sub_unit' => ((isset($country['currency_sub_unit'])) ? $country['currency_sub_unit'] : null), |
|
38
|
|
|
'full_name' => ((isset($country['full_name'])) ? $country['full_name'] : null), |
|
39
|
|
|
'iso_3166_2' => $country['iso_3166_2'], |
|
40
|
|
|
'iso_3166_3' => $country['iso_3166_3'], |
|
41
|
|
|
'name' => $country['name'], |
|
42
|
|
|
'region_code' => $country['region-code'], |
|
43
|
|
|
'sub_region_code' => $country['sub-region-code'], |
|
44
|
|
|
'eea' => (bool)$country['eea'], |
|
45
|
|
|
'calling_code' => $country['calling_code'], |
|
46
|
|
|
'currency_symbol' => ((isset($country['currency_symbol'])) ? $country['currency_symbol'] : null), |
|
47
|
|
|
'flag' => ((isset($country['flag'])) ? $country['flag'] : null), |
|
48
|
|
|
)); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|