| Conditions | 5 |
| Paths | 8 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 7 | ||
| Bugs | 1 | Features | 2 |
| 1 | <?php |
||
| 14 | public function jsonSerialize(): mixed |
||
| 15 | { |
||
| 16 | // get the validation rules for the field |
||
| 17 | $rules = array_map_recursive(function ($rule) { |
||
| 18 | return (string) $rule; |
||
| 19 | }, $this->validationRules()); |
||
|
|
|||
| 20 | |||
| 21 | $content = $this->content(); |
||
| 22 | $content['validators'] = $rules ? $rules[array_key_first($rules)] : []; |
||
| 23 | $content['dot_name'] = $this->input_json_dot_name; |
||
| 24 | |||
| 25 | // see if any settings fields have been added to the field |
||
| 26 | if (method_exists($this, 'hasSettings') && $this->hasSettings()) { |
||
| 27 | $content['settings'] = $this->settings(); |
||
| 28 | } |
||
| 29 | |||
| 30 | // run any field specific additions |
||
| 31 | if (method_exists($this, 'addToJson')) { |
||
| 32 | $content = $content->merge($this->addToJson()); |
||
| 33 | } |
||
| 34 | |||
| 35 | return collect([ |
||
| 36 | 'component' => $this->component(), |
||
| 37 | 'content' => $content, |
||
| 38 | ]); |
||
| 41 |