{"id":17966037,"url":"https://github.com/amdad121/route-resource-paths-laravel","last_synced_at":"2026-01-02T21:12:56.782Z","repository":{"id":258038297,"uuid":"874040687","full_name":"amdad121/route-resource-paths-laravel","owner":"amdad121","description":"Route Resource Paths Laravel Package","archived":false,"fork":false,"pushed_at":"2025-03-07T20:01:16.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-24T06:47:05.953Z","etag":null,"topics":["laravel","route","routes"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amdad121.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"amdad121"}},"created_at":"2024-10-17T06:43:21.000Z","updated_at":"2025-03-07T20:01:20.000Z","dependencies_parsed_at":"2024-10-29T13:29:16.984Z","dependency_job_id":null,"html_url":"https://github.com/amdad121/route-resource-paths-laravel","commit_stats":null,"previous_names":["amdad121/route-resource-paths-laravel"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/amdad121/route-resource-paths-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Froute-resource-paths-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Froute-resource-paths-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Froute-resource-paths-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Froute-resource-paths-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amdad121","download_url":"https://codeload.github.com/amdad121/route-resource-paths-laravel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amdad121%2Froute-resource-paths-laravel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260301993,"owners_count":22988722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","route","routes"],"created_at":"2024-10-29T13:07:01.929Z","updated_at":"2026-01-02T21:12:56.776Z","avatar_url":"https://github.com/amdad121.png","language":"PHP","funding_links":["https://github.com/sponsors/amdad121"],"categories":[],"sub_categories":[],"readme":"# Route Resource Paths Laravel Package\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/amdadulhaq/route-resource-paths-laravel.svg?style=flat-square)](https://packagist.org/packages/amdadulhaq/route-resource-paths-laravel)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/amdadulhaq/route-resource-paths-laravel/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/amdad121/route-resource-paths-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/amdad121/route-resource-paths-laravel/lint.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/amdad121/route-resource-paths-laravel/actions?query=workflow%3A\"Fix+Code+Style\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/amdadulhaq/route-resource-paths-laravel.svg?style=flat-square)](https://packagist.org/packages/amdadulhaq/route-resource-paths-laravel)\n\nThis Laravel package allows you to define custom paths for create and edit routes in resource controllers. It extends the functionality of Laravel's resource routing by providing macros to set these paths globally or for specific resources.\n\n## Features\n\n- Set global custom paths for create and edit actions across all resource routes\n- Customize paths individually for each resource route\n- Support for both regular resource routes and singleton resource routes\n- Works seamlessly with both `Route::resource()` and `Route::resources()` methods\n- Override global settings with per-resource customization\n- Zero configuration required - works out of the box\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require amdadulhaq/route-resource-paths-laravel\n```\n\nOnce installed, the service provider will be registered automatically by Laravel.\n\n## Requirements\n\n- PHP 8.2 or higher\n- Laravel 10.x, 11.x, or 12.x\n\n## Configuration\n\nNo additional configuration is required. The package uses Laravel's built-in service container to bind and replace the default resource registrar.\n\n## Usage\n\n### Setting Global Paths\n\nTo set custom paths for the create and edit actions that will apply globally to all resource routes, use the `Route::resourcePaths()` method:\n\n```php\nRoute::resourcePaths([\n    'create' =\u003e 'add',\n    'edit' =\u003e 'change',\n]);\n```\n\nAfter setting these global paths, all resource routes defined using `Route::resource()` will use these custom paths instead of the default ones.\n\n### Using Global Paths with Route::resource()\n\nThe global paths will automatically be applied to all resource controllers like this:\n\n```php\nRoute::resource('posts', PostController::class);\n```\n\nThis will generate routes such as:\n\n- `GET /posts/add` instead of `GET /posts/create`\n- `GET /posts/{post}/change` instead of `GET /posts/{post}/edit`\n\n### Using Global Paths with Route::resources()\n\nYou can also use the global paths when registering multiple resource controllers at once:\n\n```php\nRoute::resources([\n    'photos' =\u003e PhotoController::class,\n    'posts' =\u003e PostController::class,\n]);\n```\n\nThis will apply the same custom paths to both photos and posts resource routes.\n\n### Setting Custom Paths for Specific Resources\n\nIf you want to set custom paths for a specific resource, you can do so directly when defining the resource using the `paths()` method:\n\n```php\nRoute::resource('users', UserController::class)-\u003epaths([\n    'create' =\u003e 'add',\n    'edit' =\u003e 'change',\n]);\n```\n\nThis will only affect the routes for the users resource:\n\n- `GET /users/add` instead of `GET /users/create`\n- `GET /users/{user}/change` instead of `GET /users/{user}/edit`\n\n### Combining Global and Specific Paths\n\nYou can set global paths and override them for specific resources:\n\n```php\n// Set global paths\nRoute::resourcePaths([\n    'create' =\u003e 'add',\n    'edit' =\u003e 'change',\n]);\n\n// Use global paths for most resources\nRoute::resource('posts', PostController::class);\n\n// Override for specific resource\nRoute::resource('users', UserController::class)-\u003epaths([\n    'create' =\u003e 'register',\n    'edit' =\u003e 'update',\n]);\n```\n\nIn this example:\n- Posts will use `/posts/add` and `/posts/{post}/change`\n- Users will use `/users/register` and `/users/{user}/update`\n\n### Setting Paths for Multiple Resources\n\nWhen registering multiple resources with `Route::resources()`, you can apply custom paths to all of them:\n\n```php\nRoute::resources([\n    'photos' =\u003e PhotoController::class,\n    'posts' =\u003e PostController::class,\n])-\u003epaths([\n    'create' =\u003e 'add',\n    'edit' =\u003e 'modify',\n]);\n```\n\n### Singleton Resource Paths\n\nThe package also supports singleton resources. Use the `Route::singletonPaths()` method to set global singleton paths:\n\n```php\nRoute::singletonPaths([\n    'create' =\u003e 'setup',\n    'edit' =\u003e 'modify',\n]);\n```\n\nThen define your singleton resource:\n\n```php\nRoute::singleton('profile', ProfileController::class)-\u003ecreatable();\n```\n\nThis will generate the following routes:\n\n- `GET /profile/setup` instead of `GET /profile/create`\n- `GET /profile/modify` instead of `GET /profile/edit`\n\n### Custom Paths for Specific Singleton Resources\n\nYou can also set custom paths per singleton resource:\n\n```php\nRoute::singleton('profile', ProfileController::class)\n    -\u003ecreatable()\n    -\u003epaths([\n        'create' =\u003e 'setup',\n        'edit' =\u003e 'modify',\n    ]);\n```\n\n## API Reference\n\n### Route Macros\n\n#### `Route::resourcePaths(array $paths)`\n\nSets global custom paths for all resource routes.\n\n**Parameters:**\n- `$paths` (array): An associative array where keys are action names (`create`, `edit`) and values are the custom path strings.\n\n**Example:**\n```php\nRoute::resourcePaths([\n    'create' =\u003e 'add',\n    'edit' =\u003e 'change',\n]);\n```\n\n#### `Route::singletonPaths(array $paths)`\n\nSets global custom paths for all singleton resource routes.\n\n**Parameters:**\n- `$paths` (array): An associative array where keys are action names (`create`, `edit`) and values are the custom path strings.\n\n**Example:**\n```php\nRoute::singletonPaths([\n    'create' =\u003e 'setup',\n    'edit' =\u003e 'modify',\n]);\n```\n\n#### `Route::resources(array $resources)`\n\nRegisters multiple resource controllers at once and returns a chainable object that can apply custom paths.\n\n**Parameters:**\n- `$resources` (array): An associative array where keys are resource names and values are controller class names.\n\n**Returns:** An object with a `paths()` method to apply custom paths.\n\n**Example:**\n```php\nRoute::resources([\n    'photos' =\u003e PhotoController::class,\n    'posts' =\u003e PostController::class,\n])-\u003epaths([\n    'create' =\u003e 'add',\n    'edit' =\u003e 'change',\n]);\n```\n\n### Resource Registration Methods\n\n#### `PendingResourceRegistration::paths(array $paths)`\n\nSets custom paths for a specific resource registration.\n\n**Parameters:**\n- `$paths` (array): An associative array where keys are action names (`create`, `edit`) and values are the custom path strings.\n\n**Returns:** `PendingResourceRegistration` instance for method chaining.\n\n**Example:**\n```php\nRoute::resource('users', UserController::class)-\u003epaths([\n    'create' =\u003e 'register',\n    'edit' =\u003e 'update',\n]);\n```\n\n#### `PendingSingletonResourceRegistration::paths(array $paths)`\n\nSets custom paths for a specific singleton resource registration.\n\n**Parameters:**\n- `$paths` (array): An associative array where keys are action names (`create`, `edit`) and values are the custom path strings.\n\n**Returns:** `PendingSingletonResourceRegistration` instance for method chaining.\n\n**Example:**\n```php\nRoute::singleton('profile', ProfileController::class)\n    -\u003ecreatable()\n    -\u003epaths([\n        'create' =\u003e 'setup',\n        'edit' =\u003e 'modify',\n    ]);\n```\n\n## Complete Example\n\nHere's a complete example showing various ways to use the package:\n\n```php\nuse Illuminate\\Support\\Facades\\Route;\nuse App\\Http\\Controllers\\PostController;\nuse App\\Http\\Controllers\\UserController;\nuse App\\Http\\Controllers\\ProfileController;\n\n// routes/web.php\n\n// Set global paths for all resources\nRoute::resourcePaths([\n    'create' =\u003e 'add',\n    'edit' =\u003e 'change',\n]);\n\n// Set global paths for all singleton resources\nRoute::singletonPaths([\n    'create' =\u003e 'setup',\n    'edit' =\u003e 'modify',\n]);\n\n// Posts will use global paths: /posts/add, /posts/{post}/change\nRoute::resource('posts', PostController::class);\n\n// Users will override global paths: /users/register, /users/{user}/update\nRoute::resource('users', UserController::class)-\u003epaths([\n    'create' =\u003e 'register',\n    'edit' =\u003e 'update',\n]);\n\n// Multiple resources with shared custom paths\nRoute::resources([\n    'photos' =\u003e PhotoController::class,\n    'albums' =\u003e AlbumController::class,\n])-\u003epaths([\n    'create' =\u003e 'upload',\n    'edit' =\u003e 'edit',\n]);\n\n// Singleton with custom paths\nRoute::singleton('profile', ProfileController::class)\n    -\u003ecreatable()\n    -\u003epaths([\n        'create' =\u003e 'setup',\n        'edit' =\u003e 'modify',\n    ]);\n```\n\n## Troubleshooting\n\n### Paths not working\n\nIf the custom paths are not working:\n\n1. Ensure the service provider is registered (it should be auto-discovered in Laravel)\n2. Check that you're calling the macro methods before defining your resources\n3. Verify the package is installed correctly by checking `composer show amdadulhaq/route-resource-paths-laravel`\n\n### Conflicts with other packages\n\nIf you're using other packages that also modify the resource registrar, ensure there are no conflicts by:\n\n1. Checking the order of service provider registration\n2. Testing with a fresh Laravel installation\n3. Reviewing other packages' documentation\n\n## Migration Guide\n\nIf you're upgrading from an older version:\n\n1. No breaking changes - the API remains the same\n2. Check the changelog for new features and improvements\n3. Ensure your Laravel version meets the requirements (10.x, 11.x, or 12.x)\n\n## Credits\n\n- [Amdadul Haq](https://github.com/amdad121)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n## Contributing\n\nIf you find any issues or have suggestions for improvements, feel free to create a pull request or open an issue on the [GitHub repository](https://github.com/amdad121/route-resource-paths-laravel).\n\n## Support\n\nFor support, email amdadulhaq781@gmail.com or open an issue on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famdad121%2Froute-resource-paths-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famdad121%2Froute-resource-paths-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famdad121%2Froute-resource-paths-laravel/lists"}