Extends
Text
* has the same features
# Make
The Number field is an extension of Text,
which by default sets type=number
and has additional methods.
use MoonShine\Fields\Number; //... public function fields(): array{ return [ Number::make('Sort') ];} //...
# Attributes
The Number field has additional attributes (besides the standard attributes of the Text field), which can be set through the appropriate methods.
Methods min()
and max()
are used to set the minimum and maximum values of a field.
min(int|float $min)
max(int|float $max)
The step()
method is used to specify a step value for a field.
step(int|float $step)
use MoonShine\Fields\Number; //...public function fields(): array{ return [ Number::make('Price') ->min(0) ->max(100000) ->step(5) ];} //...
# Stars
The stars()
method is used to display a numeric value
when previewing in the form of stars (for example, for ratings).
stars()
use MoonShine\Fields\Number; //... public function fields(): array{ return [ Number::make('Rating') ->stars() ->min(1) ->max(10) ];} //...
# +/- buttons
The buttons()
method allows you to add buttons to a field for increasing or decreasing a value.
buttons()
use MoonShine\Fields\Number; //... public function fields(): array{ return [ Number::make('Rating') ->buttons() ];} //...