1 | <?php |
||
16 | abstract class Migration extends IlluminateMigration |
||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Properties |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | /** |
||
24 | * The table name. |
||
25 | * |
||
26 | * @var string|null |
||
27 | */ |
||
28 | protected $table; |
||
29 | |||
30 | /** |
||
31 | * The table prefix. |
||
32 | * |
||
33 | * @var string|null |
||
34 | */ |
||
35 | protected $prefix; |
||
36 | |||
37 | /* ----------------------------------------------------------------- |
||
38 | | Getters & Setters |
||
39 | | ----------------------------------------------------------------- |
||
40 | */ |
||
41 | |||
42 | /** |
||
43 | * Get a schema builder instance for the connection. |
||
44 | * |
||
45 | * @return \Illuminate\Database\Schema\Builder |
||
46 | */ |
||
47 | protected function getSchemaBuilder(): Builder |
||
55 | |||
56 | /** |
||
57 | * Set the migration connection name. |
||
58 | * |
||
59 | * @param string $connection |
||
60 | * |
||
61 | * @return $this |
||
62 | */ |
||
63 | public function setConnection($connection) |
||
69 | |||
70 | /** |
||
71 | * Get the prefixed table name. |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | public function getTableName() |
||
81 | |||
82 | /** |
||
83 | * Set the table name. |
||
84 | * |
||
85 | * @param string $table |
||
86 | * |
||
87 | * @return $this |
||
88 | */ |
||
89 | public function setTable($table) |
||
95 | |||
96 | /** |
||
97 | * Set the prefix name. |
||
98 | * |
||
99 | * @param string $prefix |
||
100 | * |
||
101 | * @return $this |
||
102 | */ |
||
103 | public function setPrefix($prefix) |
||
109 | |||
110 | /* ----------------------------------------------------------------- |
||
111 | | Main Methods |
||
112 | | ----------------------------------------------------------------- |
||
113 | */ |
||
114 | |||
115 | /** |
||
116 | * Migrate to database. |
||
117 | */ |
||
118 | abstract public function up(): void; |
||
119 | |||
120 | /** |
||
121 | * Rollback the migration. |
||
122 | */ |
||
123 | public function down(): void |
||
127 | |||
128 | /** |
||
129 | * Create Table Schema. |
||
130 | * |
||
131 | * @param \Closure $blueprint |
||
132 | */ |
||
133 | protected function createSchema(Closure $blueprint): void |
||
137 | |||
138 | /** |
||
139 | * Modify a table on the schema. |
||
140 | * |
||
141 | * @param \Closure $callback |
||
142 | */ |
||
143 | protected function table(Closure $callback): void |
||
147 | |||
148 | /* ----------------------------------------------------------------- |
||
149 | | Check Methods |
||
150 | | ----------------------------------------------------------------- |
||
151 | */ |
||
152 | |||
153 | /** |
||
154 | * Check if connection exists. |
||
155 | * |
||
156 | * @return bool |
||
157 | */ |
||
158 | protected function hasConnection(): bool |
||
162 | |||
163 | /** |
||
164 | * Check if table has prefix. |
||
165 | * |
||
166 | * @return bool |
||
167 | */ |
||
168 | protected function hasPrefix(): bool |
||
172 | |||
173 | /** |
||
174 | * Check if the value is not empty. |
||
175 | * |
||
176 | * @param string|null $value |
||
177 | * |
||
178 | * @return bool |
||
179 | */ |
||
180 | private function isNotEmpty($value): bool |
||
184 | } |
||
185 |