vendredi 9 mars 2018

Notification don't work on queue but work as Direct

i have a issue with notifications on laravel, if i send a notification directly without a queue this work as well

this notifiction needs send a email and save in database

i use this to call notify as exemple

$user = \App\User::find(2);
    $candidato = \App\CandidatoVaga::where('id_user','=','1')->first();
    $user->notify(new \App\Notifications\ConviteVagaCandidato($candidato));

And this is \App\Notifications\ConviteVagaCandidato

<?php

namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class ConviteVagaCandidato extends Notification implements ShouldQueue
{
use Queueable;
protected $CandidatoVaga;
/**
 * Create a new notification instance.
 *
 * @return void
 */
public function __construct(\App\CandidatoVaga $CandidatoVaga)
{
    $this->CandidatoVaga = $CandidatoVaga;
}
/**
 * Get the notification's delivery channels.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function via($notifiable)
{
    return ['database','mail'];
}

/**
 * Get the mail representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return \Illuminate\Notifications\Messages\MailMessage
 */
public function toMail($notifiable)
{
    return (new MailMessage)
    ->greeting('Olá, '.$this->CandidatoVaga->user->DadosPessoais->nome)
    ->subject('Convite para seleção no IzyJob')
    ->markdown('email.convite_selecao');
}
/**
 * Get the array representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function toArray($notifiable)
{
return [
        'id_vaga' => $this->CandidatoVaga->id_vaga,
        'id_user' => $this->CandidatoVaga->id_user,
        'mensagem' => 'Você foi pré selecionado para a vaga',
        'tipo' => 'Nova Vaga',
    ];
}
}

This return a sql error SQLSTATE[42601]: Syntax error: 7 ERRO but without implements ShouldQueue works as well



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2GaJyYi
via IFTTT

Aucun commentaire:

Enregistrer un commentaire