Closed sasokovacic closed 4 years ago
You should post your stack trace or it's difficult to find what's the problem.
You're not identifying a tenant before your if
conditional. The before()
is only called before the command listed in $schedule->command()
is run. They run in different contexts.
Closing this issue. If you are still having issues with the package, please create a new issue. Thank you
Description
I want to run scheduled tasks for tenants. I've copied code from the documentation (https://tenancy.dev/docs/hyn/5.4/laravel-scheduler) and it's not working. Tenant is not resolved in the schedule() method of the App\Console\Kernel class.
Actual behavior
The if (app(\Hyn\Tenancy\Environment::class)->tenant()) { is never executed because tenant() method returns null. A tenant is only resolved inside of the before() method.
Expected behavior
Tenants should be resolved inside the App\Console\Kernel@schedule method as shown in the documentation.
Information