Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
37 | public function set($model, $key, $value, $attributes) |
||
38 | { |
||
39 | if (is_null($value)) { |
||
40 | return null; |
||
41 | } |
||
42 | |||
43 | if ($value instanceof Collection) { |
||
44 | $value = $value->toJson(); |
||
45 | } else { |
||
46 | $value = json_encode($value); |
||
47 | |||
48 | if ($value === false) { |
||
49 | throw JsonEncodingException::forAttribute($this, $key, json_last_error_msg()); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | return parent::set($model, $key, $value, $attributes); |
||
54 | } |
||
55 | } |
||
56 |