Estoy creando notificaciones de la base de datos de laravel 5.3. He creado notificaciones según el video publicado en https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/10 , ahora quiero agregar campos personalizados a la tabla de notificación según mis requisitos. Por favor, ayúdenme a pasar datos personalizados a la notificación y acceder a ellos.
Cuando necesitaba poner campos personalizados en Notificación, simplemente ponía el campo de datos, ya que es un campo Json, funciona perfectamente. Como esto:
namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; class TaskNotification extends Notification { use Queueable; private $message; /** * @param String $message */ public function __construct($message=false) { if ($message) $this->message = $message; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return ['database']; } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { return [ 'message' => $this->message, 'link' => route('mymodel.show'), 'task'=> 1, // This is one variable which I've created 'done'=> 0 // This is one variable which I've created ]; } }