How to add "except" rule in Route::resources?

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Mastering Route Exclusions in Laravel: How to Add "Except" Rules to Route::resources

As developers working within the Laravel ecosystem, we constantly seek ways to streamline our routing definitions. One common requirement is the need for fine-grained control over which routes are exposed, especially when dealing with resource controllers. Today, we dive into a specific pain point: how to implement an "except" rule when using the convenient Route::resources() method in Laravel.

The desire often arises from wanting to define a standard set of routes (like those generated by a resource) but explicitly exclude certain actions, such as an edit or destroy, for specific endpoints, mirroring functionality seen in methods like only within Route::apiResources().

The Misconception: except in Route::resources

When attempting to apply filtering logic directly to Route::resources() using an except array parameter, developers often encounter issues. While the concept seems logically sound—filtering the generated routes—the underlying implementation of how Laravel handles resource routing via this specific method does not expose a direct mechanism for route exclusion parameters like only or except.

This discrepancy is frequently observed when comparing API resource routing (Route::apiResources()) with standard resource routing (Route::resources()). As noted in community discussions, the methods handle route generation and filtering differently based on their intended use case. Attempting to force an except parameter onto Route::resources() results in errors or unexpected behavior because the method prioritizes generating all defined resource routes rather than accepting exclusion rules at this stage.

The Developer Solution: Explicit Route Definition

Since direct filtering isn't available within the facade method itself, the most robust and idiomatic Laravel solution is to handle route exclusions after or instead of relying solely on automatic resource generation. This gives you full control over the routing structure, which is crucial for maintaining clean, predictable application architecture, aligning with best practices promoted by the team at laravelcompany.com.

Instead of trying to filter the output of Route::resources(), we should define our routes explicitly, which allows us to precisely control what endpoints are accessible.

Implementing Route Exclusion Manually

If you need to define a set of resource routes but exclude specific actions (like edit or destroy), defining them manually provides the necessary flexibility:

use Illuminate\Support\Facades\Route;

Route::middleware('web')->group(function () {
    // Define standard resource routes for 'designations' and 'locations'
    Route::resource('designations', 'DesignationController');
    Route::resource('locations', 'LocationController');

    // Example of explicitly defining the desired routes without 'edit' actions
    // For designations, we only define index and show (excluding edit/update/destroy)
    Route::get('/designations', [DesignationController::class, 'index']);
    Route::get('/designations/{designation}', [DesignationController::class, 'show']);

    // Example: Defining a location route without the 'edit' action
    Route::get('/locations', [LocationController::class, 'index']);
});

Best Practices for Route Management

Relying on explicit route definitions, rather than trying to force filtering into facade methods, leads to more maintainable code. This approach ensures that your routing logic is transparent and easily debuggable. When managing complex applications, especially those utilizing resource controllers, maintaining clear control over the URI structure is paramount. Always favor explicit declarations when fine-grained control is required, ensuring adherence to solid architectural principles.

Conclusion

While the desire to use a simple except parameter within Route::resources() is understandable, Laravel routes are designed to offer flexibility through explicit route definition. By shifting our strategy from trying to filter resource generation to defining the required routes manually, we gain the control necessary to exclude specific actions like 'edit' or 'destroy'. This results in cleaner code and a more predictable routing structure for your application.