Issues (25)

src/Model/Region.php (6 issues)

1
<?php
2
3
namespace SilverCommerce\GeoZones\Model;
4
5
use RegionMigrationTask;
6
use SilverStripe\ORM\DB;
7
use SilverStripe\ORM\DataObject;
8
use SilverStripe\Control\Controller;
9
10
/**
11
 * Subdivisions of a country, based on ISO-3166-2 standards.
12
 * 
13
 * Thanks to debian (https://salsa.debian.org/iso-codes-team/iso-codes/blob/master/data/iso_3166-2.json)
14
 * for the base data set
15
 */
16
class Region extends DataObject
17
{
18
    /**
19
     * Syncronise codes on dev/build
20
     */
21
    private static $create_on_build = true;
0 ignored issues
show
The private property $create_on_build is not used, and could be removed.
Loading history...
22
23
    private static $table_name = "GeoZoneRegion";
0 ignored issues
show
The private property $table_name is not used, and could be removed.
Loading history...
24
25
    private static $db = [
0 ignored issues
show
The private property $db is not used, and could be removed.
Loading history...
26
        "Name" => "Varchar",
27
        "Type" => "Varchar",
28
        "Code" => "Varchar(3)",
29
        "CountryCode" => "Varchar(2)"
30
    ];
31
32
    private static $belongs_many_many = [
0 ignored issues
show
The private property $belongs_many_many is not used, and could be removed.
Loading history...
33
        'Zones' => Zone::class
34
    ];
35
36
    private static $summary_fields = [
0 ignored issues
show
The private property $summary_fields is not used, and could be removed.
Loading history...
37
        "CountryCode",
38
        "Name",
39
        "Type",
40
        "Code"
41
    ];
42
43
    private static $default_sort = [
0 ignored issues
show
The private property $default_sort is not used, and could be removed.
Loading history...
44
        "CountryCode" => "ASC",
45
        "Name" => "ASC"
46
    ];
47
48
    public function requireDefaultRecords()
49
    {
50
        parent::requireDefaultRecords();
51
52
		if (RegionMigrationTask::config()->run_during_dev_build) {
53
			$task = new RegionMigrationTask();
54
			$task->up();
55
		}
56
    }
57
}