Conditions | 5 |
Paths | 7 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
51 | public function set($model, $key, $value, $attributes) |
||
52 | { |
||
53 | if (is_array($value)) { |
||
54 | $values = ''; |
||
55 | foreach ($value as $k => $v) { |
||
56 | $values .= ($values ? ',' : '')."'$k','$v'"; |
||
57 | } |
||
58 | |||
59 | return !empty($values) ? DB::raw("column_create($values)") : null; |
||
60 | } else { |
||
61 | return $value; |
||
62 | } |
||
65 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: