D
D
Dmitry2020-07-11 10:41:18
Laravel
Dmitry, 2020-07-11 10:41:18

Why doesn't functionality work in Laravel Job?

In general, I have such a Job

public function handle()
    {        
        $data = $this->data;

        // шлем письмо
        Mail::send('emails.mailing', $data['content'], function($message) use ($data)
        {
            $message->from(env('MAIL_FROM_ADDRESS'), "name");
            $message->to($data['to']);
            $message->subject($data['subject']);
        });   

        // логгируем отправленное письмо
        $log = new MailingLog;
        $log->data = json_encode($data);
        $log->save();

        return;
    }

The problem is that the letter is sent perfectly, but it is not added to the database (new MailingLog)! Why is this?
An interesting observation: when QUEUE_CONNECTION=sync is specified in .env, then a log is WRITTEN to the database,
and if I set QUEUE_CONNECTION=database , then the log entry is NOT written to the database.
What is the reason for this behavior? And how can I solve this issue?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2020-07-11
@Alex_Wells

Very interesting (not).
Start the queue.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question