Skip to content

Commit

Permalink
Merge pull request #609 from Laravel-Backpack/use-single-source-of-tr…
Browse files Browse the repository at this point in the history
…uth-for-docs-routes

remove ambiguous extra route reference
  • Loading branch information
pxpm authored Oct 15, 2024
2 parents 89d7d9e + 5659d4d commit 993f068
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
20 changes: 1 addition & 19 deletions 6.x/crud-how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,7 @@ In addition the usual CRUD functionality, Backpack also allows you to do a few m
<a name="how-to-add-extra-crud-routes"></a>
### How to add extra CRUD routes

Starting with Backpack\CRUD 4.0, routes are defined inside the Controller, in methods that look like ```setupOperationNameRoutes()```; you can use this naming convention to setup extra routes, for your custom operations:

```php
protected function setupModerateRoutes($segment, $routeName, $controller) {
Route::get($segment.'/{id}/moderate', [
'as' => $routeName.'.moderate',
'uses' => $controller.'@moderate',
'operation' => 'moderate',
]);

Route::post($segment.'/{id}/moderate', [
'as' => $routeName.'.saveModeration',
'uses' => $controller.'@saveModeration',
'operation' => 'moderate',
]);
}
```

If you want the route to point to a different controller, you can add the route in ```routes/backpack/custom.php``` instead.
See: [How to add extra CRUD routes](/docs/{{version}}/crud-operations#operation-routes)

<a name="views"></a>
## Views
Expand Down
20 changes: 1 addition & 19 deletions 7.x-dev/crud-how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,7 @@ In addition the usual CRUD functionality, Backpack also allows you to do a few m
<a name="how-to-add-extra-crud-routes"></a>
### How to add extra CRUD routes

Starting with Backpack\CRUD 4.0, routes are defined inside the Controller, in methods that look like ```setupOperationNameRoutes()```; you can use this naming convention to setup extra routes, for your custom operations:

```php
protected function setupModerateRoutes($segment, $routeName, $controller) {
Route::get($segment.'/{id}/moderate', [
'as' => $routeName.'.moderate',
'uses' => $controller.'@moderate',
'operation' => 'moderate',
]);

Route::post($segment.'/{id}/moderate', [
'as' => $routeName.'.saveModeration',
'uses' => $controller.'@saveModeration',
'operation' => 'moderate',
]);
}
```

If you want the route to point to a different controller, you can add the route in ```routes/backpack/custom.php``` instead.
See: [How to add extra CRUD routes](/docs/{{version}}/crud-operations#operation-routes)

<a name="views"></a>
## Views
Expand Down

0 comments on commit 993f068

Please sign in to comment.