These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Encore\Admin\Form\Field; |
||
4 | |||
5 | class Currency extends Text |
||
6 | { |
||
7 | /** |
||
8 | * @var string |
||
9 | */ |
||
10 | protected $symbol = '$'; |
||
11 | |||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | protected static $js = [ |
||
16 | '/vendor/laravel-admin/AdminLTE/plugins/input-mask/jquery.inputmask.bundle.min.js', |
||
17 | ]; |
||
18 | |||
19 | /** |
||
20 | * @see https://github.com/RobinHerbots/Inputmask#options |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $options = [ |
||
25 | 'alias' => 'currency', |
||
26 | 'radixPoint' => '.', |
||
27 | 'prefix' => '', |
||
28 | 'removeMaskOnSubmit' => true, |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * Set symbol for currency field. |
||
33 | * |
||
34 | * @param string $symbol |
||
35 | * |
||
36 | * @return $this |
||
37 | */ |
||
38 | public function symbol($symbol) |
||
39 | { |
||
40 | $this->symbol = $symbol; |
||
41 | |||
42 | return $this; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Set digits for input number. |
||
47 | * |
||
48 | * @param int $digits |
||
49 | * |
||
50 | * @return $this |
||
51 | */ |
||
52 | public function digits($digits) |
||
53 | { |
||
54 | return $this->options(compact('digits')); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function prepare($value) |
||
61 | { |
||
62 | return (float) $value; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | public function render() |
||
69 | { |
||
70 | $this->inputmask($this->options); |
||
71 | |||
72 | $this->prepend($this->symbol) |
||
73 | ->defaultAttribute('style', 'width: 120px'); |
||
74 | |||
75 | return parent::render(); |
||
0 ignored issues
–
show
Bug
Compatibility
introduced
by
Loading history...
|
|||
76 | } |
||
77 | } |
||
78 |