Skip to content

Commit

Permalink
Merge pull request #306 from tightenco/jbk/remove-router-macro
Browse files Browse the repository at this point in the history
Remove Route facade macros
  • Loading branch information
bakerkretzmar authored Jun 27, 2020
2 parents bc94fd1 + 26c694e commit b6ea70f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 242 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Breaking changes are marked with ⚠️.
- ⚠️ Update `ziggy:generate` output path for Laravel 5.7+ `resources` directory structure, thanks [@Somethingideally](https://github.com/Somethingideally)! ([#269](https://github.com/tightenco/ziggy/pull/269))
- ⚠️ Update automatic `id` parameter detection to check for higher priority named route parameters and allow passing `id` as a query parameter ([#301](https://github.com/tightenco/ziggy/pull/301))

**Removed**

- ⚠️ Remove `Route` Facade macros `Route::only()` and `Route::except()` (previously `Route::whitelist()` and `Route::blacklist()`) ([#306](https://github.com/tightenco/ziggy/pull/306))

**Fixed**

- Fix automatic `id` parameter detection by also excluding routes with an _optional_ `id` parameter (`{id?}`), thanks [@Livijn](https://github.com/Livijn)! ([#263](https://github.com/tightenco/ziggy/pull/263))
Expand Down
25 changes: 2 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Ziggy supports all versions of Laravel from `5.4` to `7.x`.
- [Default Values](#default-values)
- [Filtering Routes](#filtering-routes)
- [Basic Filtering](#basic-filtering)
- [Basic Filtering using Macros](#basic-filtering-using-macros)
- [Advanced Filtering using Groups](#advanced-filtering-using-groups)
- [Filtering using Groups](#filtering-using-groups)
- [Other Useful Methods](#other-useful-methods)
- [`current()`](#current)
- [`check()`](#check)
Expand Down Expand Up @@ -140,27 +139,7 @@ return [

As shown in the example above, Ziggy can use asterisks as wildcards in route filter patterns. `home` will only match the route named `home`, whereas `api.*` will match any route whose name begins with `api.`, such as `api.posts.index` and `api.users.show`.

#### Basic Filtering using Macros

You can also filter routes using the following macros:

```php
Route::only(function () {
Route::get('...')->name('posts');
});

Route::only()->get('...')->name('posts');
```

```php
Route::except(function () {
Route::get('...')->name('posts');
});

Route::except()->get('...')->name('posts');
```

#### Advanced Filtering using Groups
#### Filtering using Groups

You can also optionally define multiple groups of included routes using a `groups` key in your `config/ziggy.php`:

Expand Down
53 changes: 0 additions & 53 deletions src/Macro.php

This file was deleted.

13 changes: 1 addition & 12 deletions src/ZiggyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@

namespace Tightenco\Ziggy;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;

class ZiggyServiceProvider extends ServiceProvider
{
public function boot()
{
Route::macro('except', function ($group = null) {
return Macro::except($this, $group);
});

Route::macro('only', function ($group = null) {
return Macro::only($this, $group);
});

if ($this->app->resolved('blade.compiler')) {
$this->registerDirective($this->app['blade.compiler']);
} else {
Expand All @@ -27,9 +18,7 @@ public function boot()
}

if ($this->app->runningInConsole()) {
$this->commands([
CommandRouteGenerator::class,
]);
$this->commands(CommandRouteGenerator::class);
}
}

Expand Down
154 changes: 0 additions & 154 deletions tests/Unit/MacroTest.php

This file was deleted.

0 comments on commit b6ea70f

Please sign in to comment.