Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nikolaysav/nova-percent-field
Laravel Nova field for displaying percents
https://github.com/nikolaysav/nova-percent-field
field laravel nova percent vue
Last synced: 4 days ago
JSON representation
Laravel Nova field for displaying percents
- Host: GitHub
- URL: https://github.com/nikolaysav/nova-percent-field
- Owner: NikolaySav
- Created: 2018-09-25T15:07:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T00:43:33.000Z (3 months ago)
- Last Synced: 2024-10-14T02:36:35.068Z (about 1 month ago)
- Topics: field, laravel, nova, percent, vue
- Language: PHP
- Size: 164 KB
- Stars: 21
- Watchers: 2
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Percent field for Laravel Nova
Laravel Nova field for displaying percents
Usually percents are stored in the database in a decimal form (e.g. 0.1615 which equals to 16.15%).
In order to simplify formatting one can use this package.### 1. Index view
![screenshot 1](https://raw.githubusercontent.com/NikolaySav/nova-percent-field/master/docs/index.png)
### 2. Detailed view
![screenshot 1](https://raw.githubusercontent.com/NikolaySav/nova-percent-field/master/docs/detailed.png)
### 3. Form view
![screenshot 1](https://raw.githubusercontent.com/NikolaySav/nova-percent-field/master/docs/form.png)## Installation
You can install the package into a Laravel app that uses [Nova](https://nova.laravel.com) via composer:
```bash
composer require nsavinov/nova-percent-field
```## Usage
Inside the resource:```php
use Nsavinov\NovaPercentField\Percent;public function fields(Request $request)
{
return [
// ...
Percent::make('Rate')
// possible options
->storedInDecimal(true) // true by default (converts 0.15 to 15.00)
->precision(2) // digits after dot
->storedInDecimal(false) // for displaying raw value from database
->displayPercentSign(true) // true by default
];
}
```