2
나는이 같은 laravel 5.3메일 알림 laravel에 조건을 추가하려면 어떻게해야합니까?
내 notication의 laravel를 사용
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Notifications\Messages\BroadcastMessage;
class GuestRegistered extends Notification implements ShouldBroadcast, ShouldQueue
{
use Queueable;
private $data;
public function __construct($data)
{
$this->data = $data;
}
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->subject('test')
->greeting('Hi')
->line('Thanks')
->line('Your password : '.$this->data)
->action('Start Shopping', url('/'));
}
}
내가 다음 ->line('Your password : '.$this->data)
표시되지 않거나 실행되지 $this->data
경우 존재하지
그래서 toMail 방법에 조건을 추가 할
어떻게해야합니까?
매개 변수가 null 인 경우 오류 : 'App \ Notifications \ GuestRegistered :: __ construct()'의 인수 1이 없습니다. 예를 들어 다음과 같이 호출합니다 :'$ event-> user-> notify (new \ App \ Notifications \ GuestRegistered());'내가 다음과 같이 호출하면 :'Notification :: send ($ guest [1], 새로운 UserRegistered $ password));', 오류가 없습니다. 따라서 두 통의 전화 양식을 통해 통보를받습니다. 어떤 파라미터가 있고 어떤 것도 가지고 있지 않습니다 –
'GuestRegistered'의 생성자에 기본값을 설정해야합니다. 내 대답 업데이트 중. – Camilo
고마워요. 그것은 작동합니다. –