Hello guys!
I´ve set Queue to send an email successfully sending via job table.
Now, I want to pass an Id from a content table, so the email sends a particular content, like choosing a campaign on MailChimp.
Let´s see some code:
CampanhaController.php
public function enviaCampanhas(Campanha $campanha)
{
$sendCampanha = Campanha::first();
// return $sendCampanha->id;
SendCampanha::dispatch($sendCampanha->id)
->delay(now()->addSeconds(5));
return 'Campanha ' . $sendCampanha->nome . ' enviada';
}
Now,. some code from SendCampanhas.php maiable
public function build(Request $request)
{
$campanha = Campanha::where('id', '=', $campanha);
return $this->view('layouts.campanhas.envia', compact('campanha'));
}
Some code from view
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
{{-- <title>{{ $campanha->nome }}</title> --}}
<!-- Styles -->
<link href="https://carbonno.nnid.test/css/app.css" rel="stylesheet">
{{-- <link href="{{ asset('css/app.css') }}" rel="stylesheet"> --}}
</head>
<body>
<span></span>
<div class="content">
<h1>AQUI VAI O TEXTO DA CAMPANHA DO CLIENTE</h1>
</div>
{!! $campanha !!}
<span class="text-center">Caso não queira mais receber essas mensagens, <a href="#!" target="_blank">clique aqui</a></span>
</body>
</html>
On the end of the day, I want to pass to this view the content from 'campanhas' table, 'texto' filed.
Looks like I can pass the variables from controller to blade, so i´ve returned the results, but it doesen´t work passing to the view.
The ``php artisan queue:wo can´t process like showing:
[2018-08-23 18:06:56][263] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:56][264] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:56][265] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][266] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][267] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][268] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][269] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][270] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][271] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][272] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][273] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][274] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][275] Processing: App\Jobs\SendCampanha
[2018-08-23 18:06:57][276] Processing: App\Jobs\SendCampanha
Now. Is this the right way to do it? If so, what I am doing wrong, or not doing to make it work?
Any helps? Hints?
Thanks in advance!