Conditions | 4 |
Paths | 4 |
Total Lines | 14 |
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 | |||
54 | if (is_array($value)) { |
||
55 | $values = ''; |
||
56 | foreach ($value as $k => $v) { |
||
57 | $values .= ($values ? ',' : '')."'$k','$v'"; |
||
58 | } |
||
59 | |||
60 | return DB::raw("column_create($values)"); |
||
61 | } |
||
62 | // elseif(object) |
||
63 | else { |
||
64 | return $value; |
||
65 | } |
||
67 | } |
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: