79542984

Date: 2025-03-29 08:49:15
Score: 2
Natty:
Report link

You shared to few details, so the answer would be general:

When you login, you rely on web or api guard to retrieve user details, including database in your case.

At the same time jobs are running without authentication in background. Job just don't have authenticated user and his details.

How to solve?

I don't know your business logic, so hard to say which to choose

At glance, I would pass database name directly to job:

class MyCustomJob 
{
public function __construct(..., protected string $dbName = 'defaultDB') {}

/** other logic */

PS:

php artisan queue:all Xcompany is something custom I guess, so there could be also some problems

Reasons:
  • Blacklisted phrase (1): How to solve
  • Whitelisted phrase (-1): in your case
  • RegEx Blacklisted phrase (1.5): How to solve?
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Oleg