1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Reedware\LaravelBlueprints; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Collection; |
6
|
|
|
|
7
|
|
|
class Columns extends Collection |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* The Table Blueprint. |
11
|
|
|
* |
12
|
|
|
* @var \Reed\Blueprints\Blueprint |
|
|
|
|
13
|
|
|
*/ |
14
|
|
|
protected $blueprint; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Create a new collection of Columns. |
18
|
|
|
* |
19
|
|
|
* @param \Reed\Blueprints\Blueprint $blueprint |
20
|
|
|
* @param mixed $columns |
21
|
|
|
* |
22
|
|
|
* @return void |
23
|
|
|
*/ |
24
|
|
|
public function __construct($columns = []) |
25
|
|
|
{ |
26
|
|
|
// Call Parent Constructor |
27
|
|
|
parent::__construct($columns); |
28
|
|
|
|
29
|
|
|
// Set the Blueprint |
30
|
|
|
$this->blueprint = $this->guessBlueprint(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Returns the Table Blueprint. |
35
|
|
|
* |
36
|
|
|
* @return \Reed\Blueprints\Blueprint |
37
|
|
|
*/ |
38
|
|
|
public function getBlueprint() |
39
|
|
|
{ |
40
|
|
|
return $this->blueprint; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Sets the Table Blueprint. |
45
|
|
|
* |
46
|
|
|
* @param \Reed\Blueprints\Blueprint $blueprint |
47
|
|
|
* |
48
|
|
|
* @return $this |
49
|
|
|
*/ |
50
|
|
|
public function setBlueprint(Blueprint $blueprint) |
51
|
|
|
{ |
52
|
|
|
$this->blueprint = $blueprint; |
|
|
|
|
53
|
|
|
|
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns the Table Blueprint using the Backtrace. |
59
|
|
|
* |
60
|
|
|
* @return \Reed\Blueprints\Blueprint|null |
61
|
|
|
*/ |
62
|
|
|
protected function guessBlueprint() |
63
|
|
|
{ |
64
|
|
|
// Determine the Caller |
65
|
|
|
[$one, $two, $caller] = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 3); |
66
|
|
|
|
67
|
|
|
// Check for Blueprint Caller |
68
|
|
|
if($caller['object'] instanceof Blueprint) { |
69
|
|
|
return $caller['object']; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
// Check for Columns Caller |
73
|
|
|
if($caller['object'] instanceof static) { |
74
|
|
|
return $caller['object']->getBlueprint(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
// Unknown Caller |
78
|
|
|
return null; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Specifies an Index on the Columns for the Table. |
83
|
|
|
* |
84
|
|
|
* @param string|null $name |
85
|
|
|
* @param string|null $algorithm |
86
|
|
|
* |
87
|
|
|
* @return \Illuminate\Support\Fluent |
88
|
|
|
*/ |
89
|
|
|
public function index($name = null, $algorithm = null) |
90
|
|
|
{ |
91
|
|
|
return $this->blueprint->index($this->pluck('name')->toArray(), $name, $algorithm); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Dynamically handle calls to the class. |
96
|
|
|
* |
97
|
|
|
* @param string $method |
98
|
|
|
* @param array $parameters |
99
|
|
|
* |
100
|
|
|
* @return mixed |
101
|
|
|
*/ |
102
|
|
|
public function __call($method, $parameters) |
103
|
|
|
{ |
104
|
|
|
// Check for Macro |
105
|
|
|
if(static::hasMacro($method)) { |
106
|
|
|
return parent::__call($method, $parameters); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
// Call the Method on the Columns |
110
|
|
|
$this->each(function($column) use ($method, $parameters) { |
111
|
|
|
$column->{$method}(...$parameters); |
112
|
|
|
}); |
113
|
|
|
|
114
|
|
|
// Allow Chaining |
115
|
|
|
return $this; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths