|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* PWWEB\Localisation\Database\Seeders\Tax\Location Seeder. |
|
5
|
|
|
* |
|
6
|
|
|
* Standard seeder for the Location Model. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Frank Pillukeit <[email protected]> |
|
9
|
|
|
* @copyright 2020 pw-websolutions.com |
|
10
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace PWWEB\Localisation\Database\Seeders\Tax; |
|
14
|
|
|
|
|
15
|
|
|
use Illuminate\Database\Seeder; |
|
16
|
|
|
use Illuminate\Support\Facades\DB; |
|
17
|
|
|
|
|
18
|
|
|
class LocationSeeder extends Seeder |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Run the database seeds. |
|
22
|
|
|
* |
|
23
|
|
|
* @return void |
|
24
|
|
|
*/ |
|
25
|
|
|
public function run() |
|
26
|
|
|
{ |
|
27
|
|
|
// Initializing variables. |
|
28
|
|
|
$createdAt = date('Y-m-d H:i:s'); |
|
29
|
|
|
$locations = []; |
|
30
|
|
|
|
|
31
|
|
|
$tableNames = config('pwweb.localisation.table_names'); |
|
32
|
|
|
|
|
33
|
|
|
// Definition of default locations. |
|
34
|
|
|
$locations[] = ['tax_rate_id' => 1, 'country_id' => 'United Kingdom']; |
|
35
|
|
|
$locations[] = ['tax_rate_id' => 1, 'country_id' => 'Croatia']; |
|
36
|
|
|
$locations[] = ['tax_rate_id' => 1, 'country_id' => 'Poland']; |
|
37
|
|
|
$locations[] = ['tax_rate_id' => 1, 'country_id' => 'Lithuania']; |
|
38
|
|
|
$locations[] = ['tax_rate_id' => 1, 'country_id' => 'Romania']; |
|
39
|
|
|
$locations[] = ['tax_rate_id' => 1, 'country_id' => 'Cyprus']; |
|
40
|
|
|
|
|
41
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'United Kingdom']; |
|
42
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Hungary']; |
|
43
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Sweden']; |
|
44
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Denmark']; |
|
45
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Poland']; |
|
46
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Ireland']; |
|
47
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Netherlands']; |
|
48
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Latvia']; |
|
49
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Belgium']; |
|
50
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Bulgaria']; |
|
51
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Germany']; |
|
52
|
|
|
$locations[] = ['tax_rate_id' => 2, 'country_id' => 'Malta']; |
|
53
|
|
|
|
|
54
|
|
|
$locations[] = ['tax_rate_id' => 3, 'country_id' => ['Luxembourg']]; |
|
55
|
|
|
|
|
56
|
|
|
$locations[] = ['tax_rate_id' => 4, 'country_id' => ['Malta']]; |
|
57
|
|
|
|
|
58
|
|
|
$locations[] = ['tax_rate_id' => 5, 'country_id' => 'Cyprus']; |
|
59
|
|
|
$locations[] = ['tax_rate_id' => 5, 'country_id' => 'Romania']; |
|
60
|
|
|
$locations[] = ['tax_rate_id' => 5, 'country_id' => 'Germany']; |
|
61
|
|
|
|
|
62
|
|
|
$locations[] = ['tax_rate_id' => 6, 'country_id' => 'Austria']; |
|
63
|
|
|
$locations[] = ['tax_rate_id' => 6, 'country_id' => 'Bulgaria']; |
|
64
|
|
|
$locations[] = ['tax_rate_id' => 6, 'country_id' => 'France']; |
|
65
|
|
|
$locations[] = ['tax_rate_id' => 6, 'country_id' => 'Slovakia']; |
|
66
|
|
|
$locations[] = ['tax_rate_id' => 6, 'country_id' => 'Estonia']; |
|
67
|
|
|
$locations[] = ['tax_rate_id' => 6, 'country_id' => 'United Kingdom']; |
|
68
|
|
|
|
|
69
|
|
|
$locations[] = ['tax_rate_id' => 7, 'country_id' => 'Belgium']; |
|
70
|
|
|
$locations[] = ['tax_rate_id' => 7, 'country_id' => 'Czech Republic']; |
|
71
|
|
|
$locations[] = ['tax_rate_id' => 7, 'country_id' => 'Latvia']; |
|
72
|
|
|
$locations[] = ['tax_rate_id' => 7, 'country_id' => 'Lithuania']; |
|
73
|
|
|
$locations[] = ['tax_rate_id' => 7, 'country_id' => 'Netherlands']; |
|
74
|
|
|
$locations[] = ['tax_rate_id' => 7, 'country_id' => 'Spain']; |
|
75
|
|
|
|
|
76
|
|
|
$locations[] = ['tax_rate_id' => 8, 'country_id' => 'Slovenia']; |
|
77
|
|
|
$locations[] = ['tax_rate_id' => 8, 'country_id' => 'Italy']; |
|
78
|
|
|
|
|
79
|
|
|
$locations[] = ['tax_rate_id' => 9, 'country_id' => 'Ireland']; |
|
80
|
|
|
$locations[] = ['tax_rate_id' => 9, 'country_id' => 'Poland']; |
|
81
|
|
|
$locations[] = ['tax_rate_id' => 9, 'country_id' => 'Portugal']; |
|
82
|
|
|
|
|
83
|
|
|
$locations[] = ['tax_rate_id' => 10, 'country_id' => 'Finland']; |
|
84
|
|
|
$locations[] = ['tax_rate_id' => 10, 'country_id' => 'Greece']; |
|
85
|
|
|
|
|
86
|
|
|
$locations[] = ['tax_rate_id' => 11, 'country_id' => 'Croatia']; |
|
87
|
|
|
$locations[] = ['tax_rate_id' => 11, 'country_id' => 'Denmark']; |
|
88
|
|
|
$locations[] = ['tax_rate_id' => 11, 'country_id' => 'Sweden']; |
|
89
|
|
|
|
|
90
|
|
|
$locations[] = ['tax_rate_id' => 12, 'country_id' => 'Hungary']; |
|
91
|
|
|
|
|
92
|
|
|
foreach ($locations as &$location) { |
|
93
|
|
|
$country = DB::table($tableNames['countries'])->where('name', $location['country_id'])->first(); |
|
94
|
|
|
$location['country_id'] = $country->id; |
|
95
|
|
|
$location = array_merge($location, ['active' => false, 'created_at' => $createdAt, 'updated_at' => $createdAt]); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
DB::table($tableNames['tax']['locations'])->insert($locations); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|