We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug I have a model with table located in mysql database and that model belong to currency as shown below:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Squire\Models\Currency; class Product extends Model { public function currency() { return $this->belongsTo(Currency::class); } }
To reproduce Make a job that contains a call of currency model for example.
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Notification; class NewProduct extends Notification implements ShouldQueue { use Queueable; public function via($notifiable) { return ['database']; } public function toArray($notifiable) { echo $this->product->currency; } }
Expected behavior The job should executed as normal jobs
Context
Additional details
[2022-10-17 23:22:02] local.ERROR: Undefined array key "Squire\Models\Currency" {"exception":"[object] (ErrorException(code: 0): Undefined array key \"Squire\\Models\\Currency\" at /Users/username/Code/php/laravel/org/project/vendor/squirephp/squire/packages/model/src/Model.php:159) [stacktrace] #0 /Users/username/Code/php/laravel/org/project/vendor/squirephp/squire/packages/model/src/Model.php(159): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'Undefined array...', '/Users/username/C...', 159) #1 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1619): Squire\\Model::resolveConnection('mysql') #2 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1425): Illuminate\\Database\\Eloquent\\Model->getConnection() #3 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1342): Illuminate\\Database\\Eloquent\\Model->newBaseQueryBuilder() #4 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1378): Illuminate\\Database\\Eloquent\\Model->newModelQuery() #5 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1331): Illuminate\\Database\\Eloquent\\Model->newQueryWithoutScopes() #6 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php(218): Illuminate\\Database\\Eloquent\\Model->newQuery() #7 /Users/username/Code/php/laravel/org/project/packages/PCsoft/PIM/Models/Product.php(169): Illuminate\\Database\\Eloquent\\Model->belongsTo('Squire\\\\Models\\\\C...') #8 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(690): PCsoft\\PIM\\Models\\Product->currency() #9 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(106): Illuminate\\Database\\Eloquent\\Builder->Illuminate\\Database\\Eloquent\\{closure}() #10 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(694): Illuminate\\Database\\Eloquent\\Relations\\Relation::noConstraints(Object(Closure)) #11 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(662): Illuminate\\Database\\Eloquent\\Builder->getRelation('currency') #12 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(642): Illuminate\\Database\\Eloquent\\Builder->eagerLoadRelation(Array, 'currency', Object(Closure)) #13 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(597): Illuminate\\Database\\Eloquent\\Builder->eagerLoadRelations(Array) #14 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(102): Illuminate\\Database\\Eloquent\\Model->load(Array) #15 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(57): Illuminate\\Notifications\\Notification->restoreModel(Object(Illuminate\\Contracts\\Database\\ModelIdentifier)) #16 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/SerializesModels.php(122): Illuminate\\Notifications\\Notification->getRestoredPropertyValue(Object(Illuminate\\Contracts\\Database\\ModelIdentifier)) #17 [internal function]: Illuminate\\Notifications\\Notification->__unserialize(Array) #18 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(97): unserialize('O:48:\"Illuminat...') #19 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(253): Illuminate\\Queue\\CallQueuedHandler->getCommand(Array) #20 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(213): Illuminate\\Queue\\CallQueuedHandler->failed(Array, Object(ErrorException), 'cd9349eb-1b4e-4...') #21 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(192): Illuminate\\Queue\\Jobs\\Job->failed(Object(ErrorException)) #22 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(581): Illuminate\\Queue\\Jobs\\Job->fail(Object(ErrorException)) #23 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(527): Illuminate\\Queue\\Worker->failJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(ErrorException)) #24 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(455): Illuminate\\Queue\\Worker->markJobAsFailedIfWillExceedMaxAttempts('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), 1, Object(ErrorException)) #25 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(432): Illuminate\\Queue\\Worker->handleJobException('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions), Object(ErrorException)) #26 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate\\Queue\\Worker->process('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions)) #27 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(172): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), 'redis', Object(Illuminate\\Queue\\WorkerOptions)) #28 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(117): Illuminate\\Queue\\Worker->daemon('redis', 'fcm:send', Object(Illuminate\\Queue\\WorkerOptions)) #29 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\\Queue\\Console\\WorkCommand->runWorker('redis', 'fcm:send') #30 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Queue\\Console\\WorkCommand->handle() #31 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #32 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure)) #33 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure)) #34 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL) #35 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call(Array) #36 /Users/username/Code/php/laravel/org/project/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #37 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #38 /Users/username/Code/php/laravel/org/project/vendor/symfony/console/Application.php(1028): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #39 /Users/username/Code/php/laravel/org/project/vendor/symfony/console/Application.php(299): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #40 /Users/username/Code/php/laravel/org/project/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #41 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #42 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #43 /Users/username/Code/php/laravel/org/project/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #44 {main} "}
The text was updated successfully, but these errors were encountered:
should be return instead of echo ?
return
echo
Sorry, something went wrong.
danharrin
No branches or pull requests
Describe the bug
I have a model with table located in mysql database and that model belong to currency as shown below:
To reproduce
Make a job that contains a call of currency model for example.
Expected behavior
The job should executed as normal jobs
Context
Additional details
The text was updated successfully, but these errors were encountered: