laravel-auth-jobs-development
Installation
SKILL.md
Laravel Auth Jobs Development
Use this skill when a queued job must access the authenticated user that dispatched it. This package captures the authenticated user ID and guard during the HTTP request and restores that auth state inside queued jobs.
Install and Publish Configuration
composer require mrpunyapal/laravel-auth-jobs
php artisan vendor:publish --tag="auth-jobs-config"
Required Workflow
- Dispatch the job from a request handled by one of the middleware groups listed in
config/auth-jobs.php. - Let the package's
AuthenticateJobsHTTP middleware store the authenticated user ID and guard in Laravel context for that request. - Add
new AuthenticateJobto the queued job'smiddleware()method so the auth state is restored beforehandle()runs. - Read
auth()->user()or run authorization checks insidehandle()after the middleware has restored the auth state. - If your application needs different context keys, replace
context_keyswith a custom class that implementsHasContextKeys, or bind the interface in a service provider.