Completed
Push — revert-4-support-laravel-5.x ( ad9bef )
by Hennik
09:26
created

MySqlGrammar::typeGeometry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace LaravelSpatial\Schema\Grammars;
4
5
use Illuminate\Support\Fluent;
6
use LaravelSpatial\Schema\Blueprint;
7
8
class MySqlGrammar extends \Illuminate\Database\Schema\Grammars\MySqlGrammar
9
{
10
    /**
11
     * Adds a statement to add a geometry column
12
     *
13
     * @param \Illuminate\Support\Fluent $column
14
     * @return string
15
     */
16 13
    public function typeGeometry(Fluent $column)
17
    {
18 13
        return 'GEOMETRY';
19
    }
20
21
    /**
22
     * Adds a statement to add a point column
23
     *
24
     * @param \Illuminate\Support\Fluent $column
25
     * @return string
26
     */
27 14
    public function typePoint(Fluent $column)
28
    {
29 14
        return 'POINT';
30
    }
31
32
    /**
33
     * Adds a statement to add a linestring column
34
     *
35
     * @param \Illuminate\Support\Fluent $column
36
     * @return string
37
     */
38 13
    public function typeLinestring(Fluent $column)
39
    {
40 13
        return 'LINESTRING';
41
    }
42
43
    /**
44
     * Adds a statement to add a polygon column
45
     *
46
     * @param \Illuminate\Support\Fluent $column
47
     * @return string
48
     */
49 13
    public function typePolygon(Fluent $column)
50
    {
51 13
        return 'POLYGON';
52
    }
53
54
    /**
55
     * Adds a statement to add a multipoint column
56
     *
57
     * @param \Illuminate\Support\Fluent $column
58
     * @return string
59
     */
60 13
    public function typeMultipoint(Fluent $column)
61
    {
62 13
        return 'MULTIPOINT';
63
    }
64
65
    /**
66
     * Adds a statement to add a multilinestring column
67
     *
68
     * @param \Illuminate\Support\Fluent $column
69
     * @return string
70
     */
71 13
    public function typeMultilinestring(Fluent $column)
72
    {
73 13
        return 'MULTILINESTRING';
74
    }
75
76
    /**
77
     * Adds a statement to add a multipolygon column
78
     *
79
     * @param \Illuminate\Support\Fluent $column
80
     * @return string
81
     */
82 13
    public function typeMultipolygon(Fluent $column)
83
    {
84 13
        return 'MULTIPOLYGON';
85
    }
86
87
    /**
88
     * Adds a statement to add a geometrycollection column
89
     *
90
     * @param \Illuminate\Support\Fluent $column
91
     * @return string
92
     */
93 13
    public function typeGeometrycollection(Fluent $column)
94
    {
95 13
        return 'GEOMETRYCOLLECTION';
96
    }
97
98
    /**
99
     * Compile a spatial index key command.
100
     *
101
     * @param  \LaravelSpatial\Schema\Blueprint $blueprint
102
     * @param  \Illuminate\Support\Fluent $command
103
     * @return string
104
     */
105
    public function compileSpatial(Blueprint $blueprint, Fluent $command)
106
    {
107
        return $this->compileKey($blueprint, $command, 'spatial');
108
    }
109
110
    /**
111
     * Compile a drop index command.
112
     *
113
     * @param  \LaravelSpatial\Schema\Blueprint $blueprint
114
     * @param  \Illuminate\Support\Fluent $command
115
     * @return string
116
     */
117
    public function compileDropSpatial(Blueprint $blueprint, Fluent $command)
118
    {
119
        $table = $this->wrapTable($blueprint);
120
121
        $index = $this->wrap($command->index);
122
123
        return "alter table {$table} drop index {$index}";
124
    }
125
}
126