@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
37 | 37 | |
38 | - if(strpos($table,"App\Models")!==false) { |
|
38 | + if (strpos($table, "App\Models") !== false) { |
|
39 | 39 | $table = new $table(); |
40 | 40 | $table = $table::$tableName; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $data = DB::table($table); |
44 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
44 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
45 | 45 | $data = call_user_func($SQLCondition, $data); |
46 | 46 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
47 | 47 | $data->whereRaw($SQLCondition); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $data = $data->get(); |
50 | 50 | $options = []; |
51 | 51 | foreach ($data as $d) { |
52 | - $options[ $d->$key_field ] = $d->$display_field; |
|
52 | + $options[$d->$key_field] = $d->$display_field; |
|
53 | 53 | } |
54 | 54 | $this->options($options); |
55 | 55 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | * @param $SQLCondition string|callable |
41 | 41 | */ |
42 | 42 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
43 | - if(strpos($table,"App\Models")!==false) { |
|
43 | + if (strpos($table, "App\Models") !== false) { |
|
44 | 44 | $table = new $table(); |
45 | 45 | $table = $table::$tableName; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $data = DB::table($table); |
49 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
49 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
50 | 50 | $data = call_user_func($SQLCondition, $data); |
51 | 51 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
52 | 52 | $data->whereRaw($SQLCondition); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $data = $data->get(); |
55 | 55 | $options = []; |
56 | 56 | foreach ($data as $d) { |
57 | - $options[ $d->$key_field ] = $d->$display_field; |
|
57 | + $options[$d->$key_field] = $d->$display_field; |
|
58 | 58 | } |
59 | 59 | $this->options($options); |
60 | 60 | } |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function optionsFromTable($table, $key_field, $display_field, $SQLCondition = null) { |
43 | 43 | |
44 | - if(strpos($table,"App\Models")!==false) { |
|
44 | + if (strpos($table, "App\Models") !== false) { |
|
45 | 45 | $table = new $table(); |
46 | 46 | $table = $table::$tableName; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $data = DB::table($table); |
50 | - if($SQLCondition && is_callable($SQLCondition)) { |
|
50 | + if ($SQLCondition && is_callable($SQLCondition)) { |
|
51 | 51 | $data = call_user_func($SQLCondition, $data); |
52 | 52 | }elseif ($SQLCondition && is_string($SQLCondition)) { |
53 | 53 | $data->whereRaw($SQLCondition); |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | $data = $data->get(); |
56 | 56 | $options = []; |
57 | 57 | foreach ($data as $d) { |
58 | - $options[ $d->$key_field ] = $d->$display_field; |
|
58 | + $options[$d->$key_field] = $d->$display_field; |
|
59 | 59 | } |
60 | 60 | $data = columnSingleton()->getColumn($this->index); |
61 | 61 | /** @var $data SelectModel */ |
62 | - $data->setOptionsFromTable(["table"=>$table,"key_field"=>$key_field,"display_field"=>$display_field,"sql_condition"=>$SQLCondition]); |
|
62 | + $data->setOptionsFromTable(["table"=>$table, "key_field"=>$key_field, "display_field"=>$display_field, "sql_condition"=>$SQLCondition]); |
|
63 | 63 | columnSingleton()->setColumn($this->index, $data); |
64 | 64 | |
65 | 65 | $this->options($options); |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | columnSingleton()->setColumn($this->index, $data); |
76 | 76 | |
77 | 77 | $result = call_user_func($query); |
78 | - if($result) { |
|
78 | + if ($result) { |
|
79 | 79 | $options = []; |
80 | - foreach($result as $r) { |
|
81 | - $options[ $r->key ] = $r->label; |
|
80 | + foreach ($result as $r) { |
|
81 | + $options[$r->key] = $r->label; |
|
82 | 82 | } |
83 | 83 | $this->options($options); |
84 | 84 | } |