1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Epesi\Core\Data; |
4
|
|
|
|
5
|
|
|
trait HasEpesiConnection |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Create atk4 model and assign default persistence |
9
|
|
|
* |
10
|
|
|
* @param array $defaults |
11
|
|
|
* |
12
|
|
|
* @return \Epesi\Core\Data\Model |
|
|
|
|
13
|
|
|
*/ |
14
|
|
|
public static function create($defaults = []) |
15
|
|
|
{ |
16
|
|
|
$atkDb = app()->make(Persistence\SQL::class); |
17
|
|
|
|
18
|
|
|
return new static($atkDb, $defaults); |
|
|
|
|
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public static function migrate() |
22
|
|
|
{ |
23
|
|
|
return \atk4\schema\Migration::getMigration(static::create())->migrate(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function addCrits($crits = []) |
27
|
|
|
{ |
28
|
|
|
foreach ($crits as $condition) { |
29
|
|
|
$this->addCondition(...$condition); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
return $this; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Get the values of a given key. |
37
|
|
|
* |
38
|
|
|
* @param string|array $value |
39
|
|
|
* @param string|null $key |
40
|
|
|
* @return static |
41
|
|
|
*/ |
42
|
|
|
public static function pluck($value, $key = null) |
43
|
|
|
{ |
44
|
|
|
return collect(self::create()->export())->pluck($value, $key); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
// to be removed for atk4/data 2.0 |
48
|
|
|
public function addFields($fields = [], $defaults = []) |
49
|
|
|
{ |
50
|
|
|
foreach ($fields as $key => $field) { |
51
|
|
|
if (!is_int($key)) { |
52
|
|
|
// field name can be passed as array key |
53
|
|
|
$name = $key; |
54
|
|
|
} elseif (is_string($field)) { |
55
|
|
|
// or it can be simple string = field name |
56
|
|
|
$name = $field; |
57
|
|
|
$field = []; |
58
|
|
|
} elseif (is_array($field) && isset($field[0]) && is_string($field[0])) { |
59
|
|
|
// or field name can be passed as first element of seed array (old behaviour) |
60
|
|
|
$name = array_shift($field); |
61
|
|
|
} else { |
62
|
|
|
// some unsupported format, maybe throw exception here? |
63
|
|
|
continue; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$seed = array_merge($defaults, (array) $field); |
67
|
|
|
|
68
|
|
|
$this->addField($name, $seed); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
} |
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