Skip to content

Commit 547af64

Browse files
author
=
committed
initial commit
0 parents  commit 547af64

15 files changed

+748
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
indent_size = 4
9+
indent_style = space
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.travis.yml export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/.scrutinizer.yml export-ignore
10+
/tests export-ignore
11+
/.editorconfig export-ignore

.github/workflows/tests.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
linux_tests:
11+
12+
runs-on: ubuntu-latest
13+
services:
14+
mysql:
15+
image: mysql:5.7
16+
env:
17+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
18+
MYSQL_DATABASE: forge
19+
ports:
20+
- 33306:3306
21+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
22+
redis:
23+
image: redis:5.0
24+
ports:
25+
- 6379:6379
26+
options: --entrypoint redis-server
27+
strategy:
28+
fail-fast: true
29+
matrix:
30+
php: [7.3, 7.4]
31+
stability: [prefer-lowest, prefer-stable]
32+
33+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v2
38+
39+
- name: Setup PHP
40+
uses: shivammathur/setup-php@v2
41+
with:
42+
php-version: ${{ matrix.php }}
43+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
44+
tools: composer:v2
45+
coverage: none
46+
47+
- name: Setup Memcached
48+
uses: niden/actions-memcached@v7
49+
50+
- name: Install dependencies
51+
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
52+
53+
- name: Execute tests
54+
run: vendor/bin/phpunit --verbose
55+
env:
56+
DB_PORT: ${{ job.services.mysql.ports[3306] }}
57+
DB_USERNAME: root
58+
59+
windows_tests:
60+
61+
runs-on: windows-latest
62+
strategy:
63+
fail-fast: true
64+
matrix:
65+
php: [7.3, 7.4]
66+
include:
67+
- php: 7.3
68+
stability: prefer-lowest
69+
- php: 7.4
70+
stability: prefer-stable
71+
72+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }} - Windows
73+
74+
steps:
75+
- name: Set git to use LF
76+
run: |
77+
git config --global core.autocrlf false
78+
git config --global core.eol lf
79+
- name: Checkout code
80+
uses: actions/checkout@v2
81+
82+
- name: Setup PHP
83+
uses: shivammathur/setup-php@v2
84+
with:
85+
php-version: ${{ matrix.php }}
86+
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, gd, pdo_mysql, fileinfo, ftp
87+
tools: composer:v2
88+
coverage: none
89+
ini-values: memory_limit=512M
90+
91+
- name: Install dependencies
92+
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
93+
94+
- name: Execute tests
95+
run: vendor/bin/phpunit --verbose

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea
2+
build
3+
composer.lock
4+
docs
5+
vendor
6+
coverage
7+
.phpunit.result.cache

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
All notable changes to `laravel-archivable` will be documented in this file
4+
5+
## 1.0.0 - 201X-XX-XX
6+
7+
- initial release

CONTRIBUTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **[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).
44+
45+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
46+
47+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48+
49+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
50+
51+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52+
53+
- **Send 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.
54+
55+
**Happy coding**!

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Joel Butcher
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Laravel Archivable
2+
3+
<p align="center">
4+
<a href="https://github.com/joelbutcher/laravel-archivable/actions"><img src="https://github.com/joelbutcher/laravel-archivable/workflows/tests/badge.svg" alt="Build Status"></a>
5+
<a href="https://packagist.org/packages/joelbutcher/laravel-archivable"><img src="https://img.shields.io/packagist/dt/joelbutcher/laravel-archivable" alt="Total Downloads"></a>
6+
<a href="https://packagist.org/packages/joelbutcher/laravel-archivable"><img src="https://img.shields.io/packagist/v/joelbutcher/laravel-archivable" alt="Latest Stable Version"></a>
7+
<a href="https://packagist.org/packages/joelbutcher/laravel-archivable"><img src="https://img.shields.io/packagist/l/joelbutcher/laravel-archivable" alt="License"></a>
8+
</p>
9+
10+
A simple package for making Laravel Eloquent models 'archivable'. This package registers three macros. One for Laravel's `\Illuminate\Database\Schema\Blueprint` class for writing migrations with the `archivedAt` directive. Two more macros are registered for Laravel's `\Illuminate\Database\Query\Builder` class, allowing calls to `archive` and `unArchive` between Eloquent relationships.
11+
12+
## Installation
13+
14+
You can install the package via composer:
15+
16+
```bash
17+
composer require joelbutcher/laravel-archivable
18+
```
19+
20+
## Usage
21+
22+
Typically, the trait works similarly to Laravels `SoftDeletes` trait. Therefore, any model that has an `archived_at` column in it's table schema can utilise the `\LaravelArchivable\Archivable` trait.
23+
24+
``` php
25+
namespace App\Models;
26+
27+
use \Illuminate\Database\Eloquent\Model;
28+
29+
class ArchivablePost extends Model {
30+
31+
use Archivable;
32+
...
33+
}
34+
```
35+
36+
### Testing
37+
38+
Currently, a test suite doesn't exist for this package. However, I will be writing tests in line with Laravel's testing schemes for traits. If you wish to contribute any unit tests of your own, please refer to the [contribution guides](#-contributing) below
39+
40+
### Changelog
41+
42+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
43+
44+
## Contributing
45+
46+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
47+
48+
### Security
49+
50+
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
51+
52+
## Credits
53+
54+
- [Joel Butcher](https://github.com/joelbutcher)
55+
56+
## License
57+
58+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
59+
60+
## Laravel Package Boilerplate
61+
62+
This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

composer.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "joelbutcher/laravel-archivable",
3+
"description": "An archivable trait package for Laravel Eloquent models",
4+
"keywords": ["laravel", "laravel-archivable"],
5+
"license": "MIT",
6+
"homepage": "https://github.com/joelbutcher/laravel-archivable",
7+
"type": "library",
8+
"support": {
9+
"issues": "https://github.com/joelbutcher/laravel-archivable/issues",
10+
"source": "https://github.com/joelbutcher/laravel-archivable"
11+
},
12+
"authors": [
13+
{
14+
"name": "Joel Butcher",
15+
"email": "[email protected]"
16+
}
17+
],
18+
"require": {
19+
"php": "^7.3|^7.4",
20+
"illuminate/support": "^8.9",
21+
"illuminate/database": "^8.9"
22+
},
23+
"require-dev": {
24+
"illuminate/pagination": "^8.9",
25+
"phpunit/phpunit": "^8.4|^9.0"
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"LaravelArchivable\\": "src"
30+
}
31+
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"LaravelArchivable\\Tests\\": "tests"
35+
}
36+
},
37+
"scripts": {
38+
"test": "vendor/bin/phpunit",
39+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
40+
41+
},
42+
"config": {
43+
"sort-packages": true
44+
},
45+
"extra": {
46+
"laravel": {
47+
"providers": [
48+
"LaravelArchivable\\LaravelArchivableServiceProvider"
49+
]
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)