我的一份工作 Laravel 有问题。(这是我第一次遇到这个问题,我有其他工作没有问题......)
我有一个监听器在一个模型更新时调度工作,所以:
一名模型观察员(工作)
观察者发起的一项活动(工作)
一个侦听前一个事件的侦听器(工作中)
一个由听众派遣的工作(不工作......)
作业已执行,但他转到我数据库中失败的作业,并显示错误“ErrorException: Undefined variable: ....” ...
很奇怪,因为所有的变量都被定义了,为什么它两次工作一次?
如果有人对此有想法,我会接受:D
提前致谢!
工作代码:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use App\Models\Transaction;
use App\Repositories\TransactionRepository;
use App\Repositories\InvoiceModelRepository;
use App\Repositories\BalanceRepository;
use Scheme;
use Log;
use Config;
use App\Helpers\HelperNumber;
use Symfony\Component\Console\Output\ConsoleOutput;
/*
sudo apt-get install supervisor
https://laravel.com/docs/5.4/queues#supervisor-configuration
php artisan queue:work --queue compute_fees --retry_after 30 --timeout 30
*/
class ComputeFees implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $id;
/**
* Create a new job instance.
*
* @param int $id
* @return void
*/
public function __construct($id)
{
$this->id = $id;
}
/**
* Get the best match of invoice models
*
* @param \App\Models\Transaction $transaction
* @return \App\Models\InvoiceModel
*/
private function getFees($transaction) {
$invoiceModelRepository = new InvoiceModelRepository();
//Get the fees for this site and payment type (And country if needed)
$params = [
'sites_id' => $transaction->site->id
];
return $params;
}
缥缈止盈