| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public function optionsFromQuery($query) { |
||
| 26 | $data = columnSingleton()->getColumn($this->index); |
||
| 27 | /** @var $data SelectQueryModel */ |
||
| 28 | $data->setOptionsFromQuery($query); |
||
| 29 | |||
| 30 | columnSingleton()->setColumn($this->index, $data); |
||
| 31 | |||
| 32 | if(is_callable($query)) { |
||
| 33 | $result = call_user_func($query); |
||
| 34 | }else{ |
||
| 35 | $result = DB::select(DB::raw($query)); |
||
| 36 | } |
||
| 37 | |||
| 38 | if($result) { |
||
| 39 | $options = []; |
||
| 40 | foreach($result as $r) { |
||
| 41 | $options[ $r->key ] = $r->label; |
||
| 42 | } |
||
| 43 | $this->options($options); |
||
| 44 | } |
||
| 45 | |||
| 46 | return $this; |
||
| 47 | } |
||
| 58 | } |