-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
232 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Security Policy | ||
|
||
If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Check & fix styling | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
style: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Run PHP CS Fixer | ||
uses: docker://oskarstark/php-cs-fixer-ga | ||
with: | ||
args: --config=.php_cs.dist.php --allow-risky=yes | ||
|
||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Fix styling. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Run tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
php: [ 8.0, 8.1 ] | ||
laravel: [ "^9.0" ] | ||
stability: [ prefer-lowest, prefer-stable ] | ||
include: | ||
- laravel: "^9.0" | ||
testbench: "^7.0" | ||
|
||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick | ||
coverage: none | ||
|
||
- name: Setup problem matchers | ||
run: | | ||
echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Install dependencies | ||
run: | | ||
composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_PASSWORD }}" | ||
composer require "illuminate/support:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update | ||
composer update --${{ matrix.stability }} --prefer-dist --no-interaction | ||
- name: Execute tests | ||
run: vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
$finder = Symfony\Component\Finder\Finder::create() | ||
->in([ | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
]) | ||
->name('*.php') | ||
->notName('*.blade.php') | ||
->ignoreDotFiles(true) | ||
->ignoreVCS(true); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRules([ | ||
'@PSR12' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'ordered_imports' => ['sort_algorithm' => 'alpha'], | ||
'no_unused_imports' => true, | ||
'not_operator_with_successor_space' => true, | ||
'trailing_comma_in_multiline' => true, | ||
'phpdoc_scalar' => true, | ||
'unary_operator_spaces' => true, | ||
'binary_operator_spaces' => true, | ||
'blank_line_before_statement' => [ | ||
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], | ||
], | ||
'phpdoc_single_line_var_spacing' => true, | ||
'phpdoc_var_without_name' => true, | ||
'class_attributes_separation' => [ | ||
'elements' => [ | ||
'method' => 'one', | ||
], | ||
], | ||
'method_argument_space' => [ | ||
'on_multiline' => 'ensure_fully_multiline', | ||
'keep_multiple_spaces_after_comma' => true, | ||
], | ||
'single_trait_insert_per_statement' => true, | ||
]) | ||
->setFinder($finder); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
# An advanced number field for Laravel Nova | ||
|
||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/simplesquid/nova-advanced-number-field.svg?style=flat-square)](https://packagist.org/packages/simplesquid/nova-advanced-number-field) | ||
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/simplesquid/nova-advanced-number-field/Run%20tests?label=tests)](https://github.com/simplesquid/nova-advanced-number-field/actions?query=workflow%3A"Run+tests"+branch%3Amain) | ||
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/simplesquid/nova-advanced-number-field/Check%20&%20fix%20styling?label=code%20style)](https://github.com/simplesquid/nova-advanced-number-field/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) | ||
[![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/simplesquid/nova-advanced-number-field.svg?style=flat-square)](https://packagist.org/packages/simplesquid/nova-advanced-number-field) | ||
|
||
A Laravel Nova field which adds additional functionality to the default Number field by using PHP's `number_format()` function. | ||
|
||
![Screenshot of the advanced number field](https://github.com/simplesquid/nova-advanced-number-field/raw/master/docs/screenshot.png) | ||
![Screenshot of the advanced number field](https://github.com/simplesquid/nova-advanced-number-field/raw/main/docs/screenshot.png) | ||
|
||
## Installation | ||
|
||
|
@@ -26,55 +28,23 @@ The `AdvancedNumber` field provides an additional 5 methods to the default `Numb | |
- `->decimals(3)`: Sets the number of decimal points to be used as well as the step value. | ||
- `->suffix('%')`: Sets the suffix to be used when displaying the number. | ||
|
||
You can use the field in your Nova resource like so: | ||
|
||
```php | ||
namespace App\Nova; | ||
|
||
use SimpleSquid\Nova\Fields\AdvancedNumber\AdvancedNumber; | ||
|
||
class User extends Resource | ||
{ | ||
// ... | ||
|
||
public function fields(Request $request) | ||
{ | ||
return [ | ||
// ... | ||
|
||
AdvancedNumber::make('Price') | ||
->prefix('$') | ||
->thousandsSeparator(','), | ||
|
||
// AdvancedNumber extends Number, so you can use Number methods too: | ||
AdvancedNumber::make('Markup') | ||
->decimals(0) | ||
->suffix('%') | ||
->min(0)->max(100), | ||
|
||
// ... | ||
]; | ||
} | ||
} | ||
``` | ||
|
||
### Testing | ||
## Testing | ||
|
||
``` bash | ||
composer test | ||
``` | ||
|
||
### Changelog | ||
## Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. | ||
|
||
### Security | ||
## Security Vulnerabilities | ||
|
||
If you discover any security related issues, please email [email protected] instead of using the issue tracker. | ||
Please review [our security policy](../../security/policy) on how to report security vulnerabilities. | ||
|
||
## Credits | ||
|
||
|
@@ -85,7 +55,7 @@ Package skeleton based on [spatie/skeleton-php](https://github.com/spatie/skelet | |
|
||
## About us | ||
|
||
SimpleSquid is a small web development and design company based in Cape Town, South Africa. | ||
SimpleSquid is a small web development and design company based in Valkenburg, Netherlands. | ||
|
||
## License | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.