Уведомление по умолчанию -> данные не работают - PullRequest
0 голосов
/ 19 июня 2019

Я пытаюсь использовать уведомление Laravel по умолчанию, но я не понимаю, почему оно не показывает данные.

Это мой код

/notification/NewReply.php

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class NewReply extends Notification
{
    use Queueable;

    public $user;
    public $association;
    public $opportunity;

    public function __construct($user, $association, $opportunity)
    {
      $this->user = $user;
      $this->opportunity = $opportunity;
      $this->association = $association;
    }

    public function via($notifiable)
    {
        return ['database'];
    }

    public function toDatabase($notifiable)
    {
        return [
          'user_id' => $this->user->id,
          'association_name' => $this->association->association_name,
          'opportunity_id' => $this->opportunity->id,
          'opportunity_name' => $this->opportunity->title,
        ];
    }
}

Вот так я запускаю уведомление

$company->notify(new NewReply(Auth::user(),$association,$opportunity));

Это поле данных, сохраненное после запуска, это правильно

{"user_id":2,"association_name":"Super delter","opportunity_id":1,"opportunity_name":"Afro tenders"}

я буду повторять это как документацию

@foreach(Auth::user()->notifications as $notification)
<p>{{$notification->data['association_name']}}</p>
@endforeach

Но я ничего не понимаю ... У кого-нибудь есть идея?

...