Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Route Patterns
rhino-project/rhino-laravel
cursor
routing
crud-routes
route-overrides
route-priority
global-controller
api-routes

Route conventions for the laravel-global-controller package

Install
php artisan boost:add-skill rhino-project/rhino-laravel

Save this content to: .cursor/rules/route-patterns.mdc

# Route Patterns

## Auto-Generated CRUD Routes

CRUD routes are auto-generated from `config/global-controller.php`. Do NOT create them manually. Register the model in config and the routes are created automatically:

```
GET    /api/{org}/{model}       → {model}.index
POST   /api/{org}/{model}       → {model}.store
GET    /api/{org}/{model}/{id}  → {model}.show
PUT    /api/{org}/{model}/{id}  → {model}.update
DELETE /api/{org}/{model}/{id}  → {model}.destroy
```

All routes are visible via `php artisan route:list`.

## Custom Route Overrides

To override a specific CRUD action:

1. Add the action to `$exceptActions` on the model:

```php
public static array $exceptActions = ['index'];
```

2. Define your custom route in `routes/api.php` ABOVE the require line:

```php
// Custom override — registered first, takes priority
Route::get('{organization}/posts', [PostController::class, 'index'])
    ->middleware(['auth:sanctum'])
    ->name('posts.index');

// Auto-generated routes (posts.index is excluded, no conflict)
require base_path('routes/global-routes.php');
```

## DON'Ts

- Don't edit `routes/global-routes.php` directly — it's a published file and may be overwritten on package update
- Don't create manual CRUD routes for models — register them in `config/global-controller.php` instead
- Don't duplicate route names that the auto-generator already creates
- Don't place custom routes BELOW the require line — they won't take priority

Route Patterns

Auto-Generated CRUD Routes

CRUD routes are auto-generated from config/global-controller.php. Do NOT create them manually. Register the model in config and the routes are created automatically:

GET    /api/{org}/{model}       → {model}.index
POST   /api/{org}/{model}       → {model}.store
GET    /api/{org}/{model}/{id}  → {model}.show
PUT    /api/{org}/{model}/{id}  → {model}.update
DELETE /api/{org}/{model}/{id}  → {model}.destroy

All routes are visible via php artisan route:list.

Custom Route Overrides

To override a specific CRUD action:

  1. Add the action to $exceptActions on the model:
public static array $exceptActions = ['index'];
  1. Define your custom route in routes/api.php ABOVE the require line:
// Custom override — registered first, takes priority
Route::get('{organization}/posts', [PostController::class, 'index'])
    ->middleware(['auth:sanctum'])
    ->name('posts.index');

// Auto-generated routes (posts.index is excluded, no conflict)
require base_path('routes/global-routes.php');

DON'Ts

  • Don't edit routes/global-routes.php directly — it's a published file and may be overwritten on package update
  • Don't create manual CRUD routes for models — register them in config/global-controller.php instead
  • Don't duplicate route names that the auto-generator already creates
  • Don't place custom routes BELOW the require line — they won't take priority
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console