Skip to content

Commit

Permalink
v3 upgrades (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdpoulter authored Nov 29, 2022
1 parent 9b7b9b6 commit f655950
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 159 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at https://editorconfig.org

root = true

[*]
Expand All @@ -14,5 +11,5 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
[*.{yml,yaml}]
indent_size = 2
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.php_cs.dist export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
1 change: 0 additions & 1 deletion CONTRIBUTING.md → .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ Before submitting a pull request:
- **One pull request per feature**: If you want to do more than one thing, send multiple pull requests.

- **Coherent history**: Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

3 changes: 3 additions & 0 deletions .github/SECURITY.md
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.
29 changes: 29 additions & 0 deletions .github/workflows/php-cs-fixer.yml
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.
50 changes: 50 additions & 0 deletions .github/workflows/run-tests.yml
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ node_modules
phpunit.xml
.phpunit.*
build
coverage

.php_cs
.php_cs.cache
psalm.xml
.php-cs-fixer.cache

.idea

.DS_Store
Thumbs.db

mix-manifest.json

40 changes: 40 additions & 0 deletions .php_cs.dist.php
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);
8 changes: 0 additions & 8 deletions .styleci.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

36 changes: 24 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,40 @@

All notable changes to `nova-advanced-number-field` will be documented in this file.

## 1.0.0 - 2019-09-07

- Initial release.

## 1.0.1 - 2019-09-07
## 3.0.0 - 2022-11-29

- Push to Packagist.
- Laravel v9 is now required
- Laravel Nova v4 is now required
- PHP 8.0 or higher is now required
- Add type-hinting
- Swap to GitHub Actions

## 1.0.2 - 2019-09-07
## 2.0.0 - 2020-04-25

- Version fix.
- Fix minimum Nova version.

## 1.0.3 - 2019-09-07
## 1.1.1 - 2019-11-01

- Version fix.
- Fix minimum Nova version.

## 1.1.0 - 2019-11-01

- Update from package template.
- Refactor and remove unnecessary code.
- Add tests.

## 1.1.1 - 2019-11-01
## 1.0.3 - 2019-09-07

- Fix minimum Nova version.
- Version fix.

## 1.0.2 - 2019-09-07

- Version fix.

## 1.0.1 - 2019-09-07

- Push to Packagist.

## 1.0.0 - 2019-09-07

- Initial release.
48 changes: 9 additions & 39 deletions README.md
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

Expand All @@ -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

Expand All @@ -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

Expand Down
24 changes: 16 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
}
],
"require": {
"php": ">=7.3.0",
"laravel/nova": "^3.0"
"php": "^8.0",
"illuminate/support": "^9.0",
"laravel/nova": "^4.0"
},
"require-dev": {
"symfony/var-dumper": "^4.3",
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^8.0"
"nunomaduro/collision": "^6.1",
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.3.3",
"symfony/var-dumper": "^6.0"
},
"autoload": {
"psr-4": {
Expand All @@ -41,13 +43,19 @@
},
"autoload-dev": {
"psr-4": {
"SimpleSquid\\Skeleton\\Tests\\": "tests"
"SimpleSquid\\Nova\\Fields\\AdvancedNumber\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": []
}
},
"scripts": {
"test": "vendor/bin/phpunit"
"test": "vendor/bin/phpunit --colors=always"
},
"config": {
"sort-packages": true
}
},
"minimum-stability": "dev"
}
Loading

0 comments on commit f655950

Please sign in to comment.