Модель обновления Laravel при отправке почты с использованием очереди - PullRequest
0 голосов
/ 03 декабря 2018

Мне удалось заставить систему очереди работать, чтобы отправить электронное письмо с вложением, но я не могу обновить модель, когда это происходит.

Конечно, я упускаю что-то простое здесь, но продолжаю получатьследующая ошибка:

exception 'ErrorException' with message 'Undefined property: App\Jobs\SendStatement::$statement' in /app/Jobs/SendStatement.php:42

Мой класс:

namespace App\Jobs;

use Mail;
use App\Mail\StatementMail;

use Carbon\Carbon;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class SendStatement implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private $statement;

    public $recipient;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($statement, $recipient)
    {
        $this->statement = $statement;
        $this->recipient = $recipient;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $email = new StatementMail($this->statement, $this->recipient);
        Mail::send($email);
        if( count(Mail::failures()) > 0 ) {

        } else {
            $this->statement->sent = Carbon::now();
            $this->statement->save();
        }
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...