1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
5
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
6
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
7
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
8
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
9
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
10
|
|
|
* THE SOFTWARE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Ytake\LaravelCouchbase\Schema; |
14
|
|
|
|
15
|
|
|
use Closure; |
16
|
|
|
use Ytake\LaravelCouchbase\Database\CouchbaseConnection; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class Builder |
20
|
|
|
* |
21
|
|
|
* @author Yuuki Takezawa<[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class Builder extends \Illuminate\Database\Schema\Builder |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* The database connection instance. |
27
|
|
|
* |
28
|
|
|
* @var \Illuminate\Database\Connection|CouchbaseConnection |
29
|
|
|
*/ |
30
|
|
|
protected $connection; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
*/ |
35
|
2 |
|
public function hasTable($table) |
36
|
|
|
{ |
37
|
|
|
try { |
38
|
2 |
|
if (!is_null($this->connection->openBucket($table)->getName())) { |
|
|
|
|
39
|
1 |
|
return true; |
40
|
|
|
} |
41
|
1 |
|
} catch (\CouchbaseException $e) { |
|
|
|
|
42
|
1 |
|
return false; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
1 |
|
public function hasColumn($table, $column) |
50
|
|
|
{ |
51
|
1 |
|
return true; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
1 |
|
public function hasColumns($table, array $columns) |
58
|
|
|
{ |
59
|
1 |
|
return true; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* needs administrator password, user |
64
|
|
|
* @param string $collection |
65
|
|
|
* @param Closure|null $callback |
66
|
|
|
* |
67
|
|
|
* @return void |
68
|
|
|
*/ |
69
|
2 |
|
public function create($collection, Closure $callback = null) |
70
|
|
|
{ |
71
|
2 |
|
$blueprint = $this->createBlueprint($collection); |
72
|
2 |
|
$blueprint->create(); |
73
|
2 |
|
sleep(5); |
74
|
2 |
|
if ($callback) { |
75
|
2 |
|
$callback($blueprint); |
76
|
|
|
} |
77
|
2 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* {@inheritdoc} |
81
|
|
|
*/ |
82
|
|
|
public function drop($collection) |
83
|
|
|
{ |
84
|
|
|
$blueprint = $this->createBlueprint($collection); |
85
|
|
|
$blueprint->drop(); |
86
|
|
|
sleep(5); |
87
|
|
|
return true; |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritdoc} |
92
|
|
|
*/ |
93
|
2 |
|
protected function createBlueprint($table, Closure $callback = null) |
94
|
|
|
{ |
95
|
2 |
|
$blueprint = new Blueprint($table, $callback); |
96
|
2 |
|
$blueprint->connector($this->connection); |
|
|
|
|
97
|
|
|
|
98
|
2 |
|
return $blueprint; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: