Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed namespace #12

Merged
merged 1 commit into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 5 additions & 47 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,16 @@ name: phpunit
on: [ push ]

jobs:
laravel_7x:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [ "7.2", "7.3", "7.4", "8.0" ]
laravel: [ "^7.0" ]

name: Laravel ${{ matrix.laravel }}, PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv
coverage: xdebug

- name: Composer self update
run: composer self-update

- name: Install dependencies
run: |
composer require laravel/framework:${{ matrix.laravel }}
composer update --prefer-stable --prefer-dist --no-progress --no-interaction

- name: Execute tests
run: |
mkdir -p build/logs
vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

laravel_8x:
phpunit:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [ "7.3", "7.4", "8.0" ]
laravel: [ "^8.0" ]
laravel: [ "^7.0", "^8.0" ]

name: Laravel ${{ matrix.laravel }}, PHP ${{ matrix.php }}
name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}

steps:
- name: Checkout code
Expand All @@ -59,15 +24,8 @@ jobs:
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv
coverage: xdebug

- name: Composer self update
run: composer self-update

- name: Install dependencies
run: |
composer require laravel/framework:${{ matrix.laravel }}
composer update --prefer-stable --prefer-dist --no-progress --no-interaction
run: composer require --dev laravel/framework:${{ matrix.laravel }}

- name: Execute tests
run: |
mkdir -p build/logs
vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
run: sudo vendor/bin/phpunit
83 changes: 47 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,59 @@
## Extended Routes

This helper extends the standard set of resource routing methods to work with SoftDeletes and other extends.

<img src="https://preview.dragon-code.pro/TheDragonCode/extended-routes.svg?brand=laravel" alt="Extended Routes"/>

<p align="center">
<a href="https://styleci.io/repos/138897572"><img src="https://styleci.io/repos/138897572/shield" alt="StyleCI" /></a>
<a href="https://github.com/andrey-helldar/extended-routes/actions"><img src="https://img.shields.io/github/workflow/status/andrey-helldar/extended-routes/phpunit?style=flat-square" alt="Github Workflow Status" /></a>
<a href="https://packagist.org/packages/andrey-helldar/extended-routes"><img src="https://img.shields.io/packagist/dt/andrey-helldar/extended-routes.svg?style=flat-square" alt="Total Downloads" /></a>
<a href="https://packagist.org/packages/andrey-helldar/extended-routes"><img src="https://img.shields.io/github/v/release/andrey-helldar/extended-routes?label=stable&style=flat-square" alt="Latest Stable Version" /></a>
<a href="https://packagist.org/packages/andrey-helldar/extended-routes"><img src="https://img.shields.io/badge/unstable-dev--master-orange?style=flat-square" alt="Latest Unstable Version" /></a>
<a href="LICENSE"><img src="https://img.shields.io/packagist/l/andrey-helldar/extended-routes.svg?style=flat-square" alt="License" /></a>
</p>
[![Stable Version][badge_stable]][link_packagist]
[![Unstable Version][badge_unstable]][link_packagist]
[![Total Downloads][badge_downloads]][link_packagist]
[![Github Workflow Status][badge_build]][link_build]
[![License][badge_license]][link_license]

> This helper extends the standard set of resource routing methods to work with SoftDeletes and other extends.


## Installation

To get the latest version of `Extended Routes`, simply require the project using [Composer](https://getcomposer.org):

```bash
$ composer require andrey-helldar/extended-routes
$ composer require dragon-code/extended-routes
```

Instead, you may of course manually update your require block and run `composer update` if you so choose:

```json
{
"require": {
"andrey-helldar/extended-routes": "^2.0"
"dragon-code/extended-routes": "^3.0"
}
}
```

For Laravel 5.4 - 6.x use `^1.0` version.
### Upgrade from `andrey-helldar/extended-routes`

1. In your `composer.json` file, replace `"andrey-helldar/extended-routes": "^2.0"` with `"dragon-code/extended-routes": "^3.0"`.
2. Replace the `Helldar\ExtendedRoutes` namespace prefix with `DragonCode\ExtendedRoutes` in your app;
3. Run the `command composer` update.
4. Profit!

## Using

Add to BaseModel method
### With trait

```php
use Helldar\ExtendedRoutes\Routing\ModelBindingResolver;
use Illuminate\Database\Eloquent\SoftDeletes;
use DragonCode\ExtendedRoutes\Routing\ModelBindingResolver;
use DragonCode\ExtendedRoutes\Traits\ExtendedSoftDeletes;

class Page extends Model
{
use SoftDeletes;

public function resolveRouteBinding($value, $field = null)
{
return (new ModelBindingResolver($this))
->resolve($value, $field);
}
use ExtendedSoftDeletes;
}
```

or change extends of model:
### Extends of the abstract model

```php
use Helldar\ExtendedRoutes\Models\ExtendedSoftDeletes;
use DragonCode\ExtendedRoutes\Models\ExtendedSoftDeletes;
//use Illuminate\Database\Eloquent\SoftDeletes;

class Foo extends ExtendedSoftDeletes
Expand All @@ -67,26 +62,26 @@ class Foo extends ExtendedSoftDeletes
}
```

or using trait:
### Routes

```php
use Helldar\ExtendedRoutes\Traits\ExtendedSoftDeletes;
//use Illuminate\Database\Eloquent\SoftDeletes; << need to remove conflicting trait.
app('router')->apiRestorableResource('foos', 'FoosController');

class Foo extends Model
{
use ExtendedSoftDeletes;
}
// or

Route::apiRestorableResource('foos', 'FoosController');
```

and for some model Foo with SoftDeletes trait we can add routes:
Referencing is also available:

```php
app('router')->apiRestorableResource('foos', 'FoosController');
use App\Http\Controllers\FoosController;

app('router')->apiRestorableResource('foos', FoosController::class);

// or

Route::apiRestorableResource('foos', 'FoosController');
Route::apiRestorableResource('foos', FoosController::class);
```

| Method | URI | Name | Action | Middleware |
Expand All @@ -99,9 +94,25 @@ Route::apiRestorableResource('foos', 'FoosController');
| DELETE | api/foos/{foo} | foos.destroy | App\Http\Controllers\FoosController@destroy | api |
| POST | api/foos/{foo}/restore | foos.restore | App\Http\Controllers\FoosController@restore | api |


## License

This package is licensed under the [MIT License](LICENSE).

This package was written with the participation of [Maksim (Ellrion) Platonov](https://github.com/Ellrion) under [MIT License](LICENSE).


[badge_build]: https://img.shields.io/github/workflow/status/TheDragonCode/extended-routes/phpunit?style=flat-square

[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/extended-routes.svg?style=flat-square

[badge_license]: https://img.shields.io/packagist/l/dragon-code/extended-routes.svg?style=flat-square

[badge_stable]: https://img.shields.io/github/v/release/TheDragonCode/extended-routes?label=stable&style=flat-square

[badge_unstable]: https://img.shields.io/badge/unstable-dev--main-orange?style=flat-square

[link_build]: https://github.com/TheDragonCode/extended-routes/actions

[link_license]: LICENSE

[link_packagist]: https://packagist.org/packages/dragon-code/extended-routes
5 changes: 0 additions & 5 deletions SECURITY.md

This file was deleted.

25 changes: 11 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "andrey-helldar/extended-routes",
"name": "dragon-code/extended-routes",
"description": "This helper extends the standard set of resource routing methods to work with SoftDeletes and other extends",
"type": "library",
"license": "MIT",
"keywords": ["extended routes", "resource", "routes", "router", "laravel"],
"keywords": ["extended routes", "resource", "routes", "router", "laravel", "dragon-code", "dragon", "andrey-helldar"],
"support": {
"issues": "https://github.com/andrey-helldar/extended-routes/issues",
"source": "https://github.com/andrey-helldar/extended-routes"
"issues": "https://github.com/TheDragonCode/extended-routes/issues",
"source": "https://github.com/TheDragonCode/extended-routes"
},
"authors": [
{
Expand All @@ -19,21 +19,18 @@
}
],
"require": {
"php": "^7.2.5|^8.0",
"illuminate/routing": "^7.30.4|^8.24",
"illuminate/support": "^7.30.4|^8.24",
"illuminate/database": "^7.30.4|^8.24"
"php": "^7.3|^8.0",
"illuminate/routing": "^7.0|^8.0",
"illuminate/support": "^7.0|^8.0",
"illuminate/database": "^7.0|^8.0"
},
"require-dev": {
"orchestra/testbench": "^5.0|^6.0",
"phpunit/phpunit": "^8.0|^9.0"
},
"suggest": {
"symfony/thanks": "Give thanks (in the form of a GitHub) to your fellow PHP package maintainers"
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
"Helldar\\ExtendedRoutes\\": "src"
"DragonCode\\ExtendedRoutes\\": "src"
}
},
"autoload-dev": {
Expand All @@ -49,7 +46,7 @@
"extra": {
"laravel": {
"providers": [
"Helldar\\ExtendedRoutes\\ServiceProvider"
"DragonCode\\ExtendedRoutes\\ServiceProvider"
]
}
}
Expand Down
50 changes: 26 additions & 24 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="phpunit.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="phpunit.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<file>src/ServiceProvider.php</file>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/logs/coverage"/>
<text outputFile="build/logs/coverage.txt"/>
</report>
</coverage>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="APP_ENV" value="testing"/>
Expand All @@ -21,17 +36,4 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<exclude>
<file>src/ServiceProvider.php</file>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-text" target="build/logs/coverage.txt"/>
<log type="coverage-html" target="build/logs/coverage"/>
</logging>
</phpunit>
2 changes: 1 addition & 1 deletion src/Contracts/Route.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Helldar\ExtendedRoutes\Contracts;
namespace DragonCode\ExtendedRoutes\Contracts;

interface Route
{
Expand Down
4 changes: 2 additions & 2 deletions src/Models/ExtendedSoftDeletes.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Helldar\ExtendedRoutes\Models;
namespace DragonCode\ExtendedRoutes\Models;

use Helldar\ExtendedRoutes\Traits\ExtendedSoftDeletes as ExtendedSoftDeletesTrait;
use DragonCode\ExtendedRoutes\Traits\ExtendedSoftDeletes as ExtendedSoftDeletesTrait;
use Illuminate\Database\Eloquent\Model;

abstract class ExtendedSoftDeletes extends Model
Expand Down
8 changes: 0 additions & 8 deletions src/Models/SoftDeletesModel.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Routing/ExtendedResourceRegistrar.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Helldar\ExtendedRoutes\Routing;
namespace DragonCode\ExtendedRoutes\Routing;

use Helldar\ExtendedRoutes\Contracts\Route;
use DragonCode\ExtendedRoutes\Contracts\Route;
use Illuminate\Routing\ResourceRegistrar;

class ExtendedResourceRegistrar extends ResourceRegistrar implements Route
Expand Down
4 changes: 2 additions & 2 deletions src/Routing/ModelBindingResolver.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Helldar\ExtendedRoutes\Routing;
namespace DragonCode\ExtendedRoutes\Routing;

use Helldar\ExtendedRoutes\Contracts\Route;
use DragonCode\ExtendedRoutes\Contracts\Route;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Str;
Expand Down
Loading