Skip to content

Commit 72fe18a

Browse files
authored
Add format method to Number Column.
formats & rounds a number with grouped thousands - 1000000 => 1,000,000.00 (If places set to 2) with variable places.
1 parent e070004 commit 72fe18a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/NumberColumn.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@ public function round($places = 0)
1818

1919
return $this;
2020
}
21+
22+
// formats & rounds a number with grouped thousands - 1000000 => 1,000,000.00 (If places set to 2)
23+
public function format($places = 2)
24+
{
25+
26+
$this->callback = function ($value) use ($places) {
27+
return number_format($value, $places, '.', ',');
28+
};
29+
30+
return $this;
31+
}
2132
}

0 commit comments

Comments
 (0)