|
7 | 7 | class Blueprint extends \Illuminate\Database\Schema\Blueprint |
8 | 8 | { |
9 | 9 |
|
| 10 | + /** |
| 11 | + * Add the index commands fluently specified on columns. |
| 12 | + * |
| 13 | + * @return void |
| 14 | + */ |
| 15 | + protected function addFluentIndexes() |
| 16 | + { |
| 17 | + foreach ($this->columns as $column) |
| 18 | + { |
| 19 | + foreach (array('primary', 'unique', 'index', 'gin') as $index) |
| 20 | + { |
| 21 | + // If the index has been specified on the given column, but is simply |
| 22 | + // equal to "true" (boolean), no name has been specified for this |
| 23 | + // index, so we will simply call the index methods without one. |
| 24 | + if ($column->$index === true) |
| 25 | + { |
| 26 | + $this->$index($column->name); |
| 27 | + |
| 28 | + continue 2; |
| 29 | + } |
| 30 | + |
| 31 | + // If the index has been specified on the column and it is something |
| 32 | + // other than boolean true, we will assume a name was provided on |
| 33 | + // the index specification, and pass in the name to the method. |
| 34 | + elseif (isset($column->$index)) |
| 35 | + { |
| 36 | + $this->$index($column->name, $column->$index); |
| 37 | + |
| 38 | + continue 2; |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Specify an index for the table. |
| 46 | + * |
| 47 | + * @param string|array $columns |
| 48 | + * @param string $name |
| 49 | + * @return \Illuminate\Support\Fluent |
| 50 | + */ |
| 51 | + public function gin($columns, $name = null) |
| 52 | + { |
| 53 | + return $this->indexCommand('gin', $columns, $name); |
| 54 | + } |
| 55 | + |
10 | 56 | /** |
11 | 57 | * Create a new character column on the table. |
12 | 58 | * |
@@ -37,7 +83,7 @@ public function uuid($column) { |
37 | 83 |
|
38 | 84 | /** |
39 | 85 | * Create a new jsonb column on the table |
40 | | - * |
| 86 | + * |
41 | 87 | * @param $column |
42 | 88 | * @return \Illuminate\Support\Fluent |
43 | 89 | */ |
|
0 commit comments