Skip to content

Commit

Permalink
Update from package template, refactor and remove unnecessary code, a…
Browse files Browse the repository at this point in the history
…nd add tests.
  • Loading branch information
mdpoulter committed Oct 30, 2019
1 parent 0de01ea commit 00bd01e
Show file tree
Hide file tree
Showing 19 changed files with 267 additions and 128 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at https://editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "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
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
composer.phar
/vendor
composer.lock
auth.json
vendor

/node_modules
package-lock.json
node_modules

phpunit.xml
.phpunit.*
phpdox.xml
build

/.idea
.idea

.DS_Store
Thumbs.db

composer.lock
auth.json
mix-manifest.json
4 changes: 4 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
preset: laravel

disabled:
- self_accessor
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: php

php:
- 7.3

env:
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""

before_script:
- travis_retry composer self-update
- composer config http-basic.nova.laravel.com ${NOVA_USERNAME} ${NOVA_PASSWORD}
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

script:
- vendor/bin/phpunit
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

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

## 1.0.0 - 2019-09-07

- Initial release.

## 1.0.1 - 2019-09-07

- Push to packagist.

## 1.0.2 - 2019-09-07

- Fix version number.

## 1.0.3 - 2019-09-27

- Cleanup codebase.
- Fix casting.

## 1.0.4 - 2019-09-27

- Add documentation.
- Refactor field code.

## 1.1.0 - 2019-09-30

- Update from package template.
- Refactor and remove unnecessary code.
- Add tests.
34 changes: 19 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# Contributing

Contributions via Pull Requests are welcome and will be fully credited.
Contributions are welcome and will be fully credited.

## Pull Requests
Please read and understand the contribution guide before creating an issue or pull request.

1. Fork the project.
## Procedure

1. `git clone` it and `composer install` the dependencies.
Before creating an issue:

1. Create a feature branch.
- Attempt to replicate the problem to ensure that it wasn't something coincidental.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

1. Make the changes you are proposing.
Before submitting a pull request:

1. Make sure the `README.md` and any other relevant documentation is kept up to date.
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

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

1. Push to your fork.
## Requirements

1. Open a pull request detailing your changes. **NB: One pull request per feature.**
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)**: The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).

## Testing
- **Tests, tests, tests!**: Your pull request won't be accepted if it doesn't have tests.

``` bash
$ phpunit
```
- **Document behaviour changes**: Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **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.
12 changes: 6 additions & 6 deletions LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)

Copyright (c) 2019 Simple Squid (Pty) Ltd
Copyright (c) Simple Squid (Pty) Ltd <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# An enum field for Laravel Nova applications
[![Latest Version](https://img.shields.io/github/release/simplesquid/nova-enum-field.svg?style=flat-square)](https://github.com/simplesquid/nova-enum-field/releases)
[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Total Downloads](https://img.shields.io/packagist/dt/simplesquid/nova-enum-field.svg?style=flat-square)](https://packagist.org/packages/simplesquid/nova-vend)

A Laravel Nova field to add enums to resources. This field uses the [BenSampo/laravel-enum](https://github.com/BenSampo/laravel-enum) package, so make sure to check out the installation instructions there first.
[![Latest Version on Packagist](https://img.shields.io/packagist/v/simplesquid/nova-enum-field.svg?style=flat-square)](https://packagist.org/packages/simplesquid/nova-enum-field)
[![Build Status](https://img.shields.io/travis/simplesquid/nova-enum-field/master.svg?style=flat-square)](https://travis-ci.org/simplesquid/nova-enum-field)
[![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-enum-field.svg?style=flat-square)](https://packagist.org/packages/simplesquid/nova-enum-field)

![Screenshot of the enum field](https://github.com/simplesquid/nova-enum-field/raw/master/img/screenshot.png)
Laravel Nova field to add enums to resources. This field uses the [BenSampo/laravel-enum](https://github.com/BenSampo/laravel-enum) package, so make sure to check out the installation instructions there first.

Contributions, issues and suggestions are very much welcome.
![Screenshot of the enum field](https://github.com/simplesquid/nova-enum-field/raw/master/docs/screenshot.png)

## Installation

You can install this package in a Laravel app that uses [Nova](https://nova.laravel.com) via composer:
You can install this package in a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```bash
composer require simplesquid/nova-enum-field
Expand Down Expand Up @@ -44,14 +44,35 @@ class User extends Resource
}
```

### Testing

``` bash
composer test
```

### Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md).
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits

- [Matthew Poulter](https://github.com/mdpoulter)
- [All Contributors](../../contributors)

Package skeleton based on [spatie/skeleton-php](https://github.com/spatie/skeleton-php).

## About us

SimpleSquid is a small web development and design company based in Cape Town, South Africa.

## License

The MIT License (MIT). Please see [License File](LICENSE) for more information.
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
43 changes: 24 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
{
"name": "simplesquid/nova-enum-field",
"license": "MIT",
"description": "A Laravel Nova field for Enums extending on bensampo/laravel-enum.",
"description": "A Laravel Nova field to add enums to resources.",
"keywords": [
"simplesquid",
"laravel",
"nova",
"field",
"enum"
"enum",
"nova-enum-field"
],
"homepage": "https://github.com/simplesquid/nova-enum-field",
"license": "MIT",
"authors": [
{
"name": "Matthew Poulter",
"email": "[email protected]",
"homepage": "https://simplesquid.co.za/",
"role": "Developer"
}
],
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
}
],
"require": {
"php": "^7.3",
"laravel/nova": "^2.0",
"illuminate/support": "^5.8|^6.0",
"bensampo/laravel-enum": "^1.26"
},
"require-dev": {
"orchestra/testbench": "^3.8|^4.0"
"symfony/var-dumper": "^4.3",
"orchestra/testbench": "^3.8|^4.0",
"phpunit/phpunit": "^8.2"
},
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
}
],
"autoload": {
"psr-4": {
"SimpleSquid\\Nova\\Fields\\Enum\\": "src/"
"SimpleSquid\\Nova\\Fields\\Enum\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"SimpleSquid\\Nova\\Fields\\Enum\\FieldServiceProvider"
]
"autoload-dev": {
"psr-4": {
"SimpleSquid\\Nova\\Fields\\Enum\\Tests\\": "tests"
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
1 change: 0 additions & 1 deletion dist/mix-manifest.json

This file was deleted.

File renamed without changes
20 changes: 0 additions & 20 deletions package.json

This file was deleted.

22 changes: 22 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Simple Squid Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
14 changes: 0 additions & 14 deletions src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@

class Enum extends Select
{
/**
* Create a new field.
*
* @param string $name
* @param string|callable|null $attribute
* @param callable|null $resolveCallback
*
* @return void
*/
public function __construct($name, $attribute = null, callable $resolveCallback = null)
{
parent::__construct($name, $attribute, $resolveCallback);
}

/**
* Setup the Enum field with the Enum class
*
Expand Down
Loading

0 comments on commit 00bd01e

Please sign in to comment.