1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: User |
5
|
|
|
* Date: 1/26/2019 |
6
|
|
|
* Time: 6:00 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace crocodicstudio\crudbooster\types; |
10
|
|
|
|
11
|
|
|
use crocodicstudio\crudbooster\controllers\scaffolding\traits\DefaultOption; |
12
|
|
|
use crocodicstudio\crudbooster\controllers\scaffolding\traits\Join; |
13
|
|
|
use crocodicstudio\crudbooster\models\ColumnModel; |
14
|
|
|
use crocodicstudio\crudbooster\types\select_table\SelectTableModel; |
15
|
|
|
use Illuminate\Support\Facades\DB; |
16
|
|
|
|
17
|
|
|
class SelectTable |
18
|
|
|
{ |
19
|
|
|
use DefaultOption, Join; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param string $field_name |
23
|
|
|
* @return $this |
24
|
|
|
*/ |
25
|
|
|
public function foreignKey($field_name) |
26
|
|
|
{ |
27
|
|
|
$data = columnSingleton()->getColumn($this->index); |
28
|
|
|
/** @var SelectTableModel $data */ |
29
|
|
|
$data->setForeignKey($field_name); |
30
|
|
|
columnSingleton()->setColumn($this->index, $data); |
31
|
|
|
|
32
|
|
|
return $this; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param $table string|Model |
|
|
|
|
37
|
|
|
* @param $value_option string |
38
|
|
|
* @param $display_option string |
39
|
|
|
* @param $SQLCondition string|callable DB Query Builder|SQL Raw |
40
|
|
|
* @return $this |
41
|
|
|
*/ |
42
|
|
|
public function optionsFromTable($table, $value_option, $display_option, $SQLCondition = null) { |
43
|
|
|
|
44
|
|
|
if(strpos($table,"App\Models")!==false) { |
45
|
|
|
$table = new $table(); |
46
|
|
|
$table = $table::$tableName; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$data = cb()->findAll($table, $SQLCondition); |
50
|
|
|
|
51
|
|
|
$options = []; |
52
|
|
|
foreach ($data as $d) { |
53
|
|
|
$options[ $d->$value_option ] = $d->$display_option; |
54
|
|
|
} |
55
|
|
|
$data = columnSingleton()->getColumn($this->index); |
56
|
|
|
/** @var $data SelectTableModel */ |
57
|
|
|
$data->setOptionsFromTable(["table"=>$table,"key_field"=>$value_option,"display_field"=>$display_option,"sql_condition"=>$SQLCondition]); |
58
|
|
|
columnSingleton()->setColumn($this->index, $data); |
59
|
|
|
|
60
|
|
|
$this->options($options); |
61
|
|
|
|
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
private function options($data_options) { |
66
|
|
|
$data = columnSingleton()->getColumn($this->index); |
67
|
|
|
/** @var $data SelectTableModel */ |
68
|
|
|
$data->setOptions($data_options); |
69
|
|
|
|
70
|
|
|
columnSingleton()->setColumn($this->index, $data); |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
} |
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