{"id":23003728,"url":"https://github.com/stechstudio/laravel-route-context","last_synced_at":"2025-07-20T22:33:03.370Z","repository":{"id":57059336,"uuid":"445266972","full_name":"stechstudio/laravel-route-context","owner":"stechstudio","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-06T19:59:53.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T14:27:17.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/stechstudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-06T18:11:56.000Z","updated_at":"2022-01-06T19:28:12.000Z","dependencies_parsed_at":"2022-08-24T14:53:27.519Z","dependency_job_id":null,"html_url":"https://github.com/stechstudio/laravel-route-context","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stechstudio/laravel-route-context","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-route-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-route-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-route-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-route-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stechstudio","download_url":"https://codeload.github.com/stechstudio/laravel-route-context/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Flaravel-route-context/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266210835,"owners_count":23893337,"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":[],"created_at":"2024-12-15T07:15:11.392Z","updated_at":"2025-07-20T22:33:03.350Z","avatar_url":"https://github.com/stechstudio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Route context in Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/stechstudio/laravel-route-context.svg?style=flat-square)](https://packagist.org/packages/stechstudio/laravel-route-context)\n\nThis is a super small package that enables you to provide additional context to your routes. Any context variables you specify will be treated as route parameters.\n\n## Installation\n\nYou know the drill...\n\n```bash\ncomposer require stechstudio/laravel-route-context\n```\n\n## Usage\n\nThe idea is that sometimes you want to reuse a controller method or Livewire fullpage component, while providing additional context at the routing layer.\n\nImagine you need to list support tickets, and you have a controller and view that handles this. You have multiple endpoints where tickets might be displayed in a slightly different manner.\n\nWith this package you can specify additional context right alongside your routes like this:\n\n```php\nRoute::get('tickets', [TicketController::class, 'index']);\nRoute::get('tickets/archived', [TicketController::class, 'index'])-\u003ewith([\n    'archived' =\u003e true\n]);\nRoute::get('tickets/mine', [TicketController::class, 'index'])-\u003ewith([\n    'user' =\u003e fn() =\u003e auth()-\u003euser()\n]);\nRoute::get('tickets/{user}', [TicketController::class, 'index']);\n```\n\nNow in your `TicketController` you can inject your context variables, just as if they had been route parameters:\n\n```php\npublic function index(User $user, $archived = false) {\n    $tickets = Tickets::query()\n        -\u003ewhen($user-\u003eexists, fn($q) =\u003e $q-\u003ewhere('user_id', $user-\u003eid))\n        -\u003ewhen(!$archived, fn($q) =\u003e $q-\u003ewhereNull('archived_at'))\n        -\u003epaginate();\n}\n```\n\nNotice that context values can be callbacks, if you need it evaluated after your app has bootstrapped, session is started, auth is available, etc.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Flaravel-route-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstechstudio%2Flaravel-route-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Flaravel-route-context/lists"}