Skip to content

Scheduler job: route not defined #849

@RaazPuspa

Description

@RaazPuspa

Description

I have been implementing cron jobs through Laravel scheduler to send some reminder emails for the clients with unsubscription options (link) attached. The job fetches every tenants and for each one select a list of contacts eligible for reminder and send them emails via queue. I have switched the tenant with the following command and can get expected set of contacts from each tenant database, but while using route() it pops an error.

app(Environment::class)->tenant($this->website)

Actual behavior

InvalidArgumentException: Route [profile.unsubscribe.show] not defined.

Expected behavior

route() should prepare url as requested as it is defined on the routes/tenants.php


Information

  • hyn/multi-tenant version: 5.4.*
  • laravel version: 5.8.*
  • database driver and version: psql (PostgreSQL) 11.5
  • webserver software and version: laravel valet
  • php version: 7.3.9

routes/tenants.php (portion of it)

$this->router
    ->name('profile.')
    ->prefix('profile')
    ->namespace('Profile')
    ->group(function () {
        $this->router->get('unsubscribe', 'UnsubscriptionController@show')
            ->name('unsubscribe.show');
        $this->router->patch('unsubscribe', 'UnsubscriptionController@update')
            ->name('unsubscribe.update');
    });

Error log

[2019-10-02 12:21:01] local.ERROR: InvalidArgumentException: Route [profile.unsubscribe.show] not defined. in /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:388
Stack trace:
#0 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(782): Illuminate\Routing\UrlGenerator->route('profile.unsubsc...', Array, true)
#1 /Users/pusparaj/sources/andatech/calibration/app/Calibration/Helpers/helpers.php(278): route('profile.unsubsc...', Array)
#2 /Users/pusparaj/sources/andatech/calibration/app/CronJobs/Tenant/CalibrationDueReminder.php(148): prepareUnsubscribeUrl(Object(App\Entities\Models\User), 'calibration_due', 2)
#3 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Support/Collection.php(475): App\CronJobs\Tenant\CalibrationDueReminder->App\CronJobs\Tenant\{closure}(Object(App\Entities\Models\Product), 0)
#4 /Users/pusparaj/sources/andatech/calibration/app/CronJobs/Tenant/CalibrationDueReminder.php(178): Illuminate\Support\Collection->each(Object(Closure))
#5 [internal function]: App\CronJobs\Tenant\CalibrationDueReminder->__invoke()
#6 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#7 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#9 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#10 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CallbackEvent.php(75): Illuminate\Container\Container->call(Array, Array)
#11 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php(111): Illuminate\Console\Scheduling\CallbackEvent->run(Object(Illuminate\Foundation\Application))
#12 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php(75): Illuminate\Console\Scheduling\ScheduleRunCommand->runEvent(Object(Illuminate\Console\Scheduling\CallbackEvent))
#13 [internal function]: Illuminate\Console\Scheduling\ScheduleRunCommand->handle()
#14 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#15 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#16 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#17 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#18 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#19 /Users/pusparaj/sources/andatech/calibration/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#20 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#21 /Users/pusparaj/sources/andatech/calibration/vendor/symfony/console/Application.php(915): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /Users/pusparaj/sources/andatech/calibration/vendor/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Console\Scheduling\ScheduleRunCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /Users/pusparaj/sources/andatech/calibration/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Console/Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /Users/pusparaj/sources/andatech/calibration/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(133): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /Users/pusparaj/sources/andatech/calibration/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 {main}  

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportQuestion or generic support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions