/ / Tabla base de notificaciones de Laravel no encontrada - mysql, laravel, notificaciones, laravel-5.5, empujador

Tabla base de notificaciones de Laravel no encontrada - mysql, laravel, notificaciones, laravel-5.5, empujador

Estoy trabajando en un proyecto de Laravel. Ejecuté estos comandos y creé con éxito la tabla de notificaciones.

php artisan notifications:table
php artisan migrate

Todas las cosas iban perfectamente. Más tarde, creé un nombre de modelo "Notificaciones para el administrador" con la migración llamada "notificaciones_para_admin", luego más tarde abandoné esta tabla. Ahora, cuando estoy tratando de generar algunas notificaciones, me está mostrando este error, no sé qué está pasando, tengo una tabla de notificaciones en la base de datos que es necesaria para las notificaciones de laravel con un esquema perfecto. el error es:

SQLSTATE[42S02]: Base table or view not found: 1146 Table "followup.notification_for_admins" doesn"t exist (SQL: select * from `notification_for_admins` where `notification_for_admins`.`user_id` = 2 and `notification_for_admins`.`user_id` is not null)

Mis notificaciones son:

<?php

namespace AppNotifications;

use IlluminateBusQueueable;
use AppUser;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesBroadcastMessage;
use IlluminateNotificationsMessagesMailMessage;
use AppEventsNewEmailReceivedEvent;
use Auth;

class NewEmailReceived extends Notification
{
use Queueable;

public $sender_id, $receiver_id, $sender_name, $receiver_name, $sender_type, $receiver_type, $type, $recipient, $from_email, $subject, $message, $image, $receiver_image, $attachments, $sizesOfAttachments, $originalFileNames, $thread_id, $id_of_email;

/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($sender_id, $receiver_id, $sender_name, $receiver_name, $sender_type, $receiver_type, $type, $recipient, $from_email, $subject, $message, $image, $receiver_image, $attachments, $sizesOfAttachments, $originalFileNames, $thread_id, $id_of_email)
{
$this->sender_id = $sender_id;
$this->receiver_id = $receiver_id;
$this->sender_name = $sender_name;
$this->receiver_name = $receiver_name;
$this->sender_type = $sender_type;
$this->receiver_type = $receiver_type;
$this->type = $type;
$this->recipient = $recipient;
$this->from_email = $from_email;
$this->subject = $subject;
$this->message = $message;
$this->image = $image;
$this->receiver_image = $receiver_image;
$this->attachments = $attachments;
$this->sizesOfAttachments = $sizesOfAttachments;
$this->originalFileNames = $originalFileNames;
$this->thread_id = $thread_id;
$this->id_of_email = $id_of_email;
}

/**
* Get the notification"s delivery channels.
*
* @param  mixed  $notifiable
* @return array
*/
public function via($notifiable)
{
$notifications = Auth::user()->notifications;
if ($notifications[7]->shown == 1) {
return ["mail", "database"];
}
else{
return ["database"];
}
}

/**
* Get the array representation of the notification.
*
* @param  mixed  $notifiable
* @return array
*/
public function toDatabase($notifiable)
{
return [
"sender_id" => $this->sender_id,
"receiver_id" => $this->receiver_id,
"sender_name" => $this->sender_name,
"receiver_name" => $this->receiver_name,
"sender_type" => $this->sender_type,
"receiver_type" => $this->receiver_type,
"type" => $this->type,
"recipient" => $this->recipient,
"from_email" => $this->from_email,
"subject" => $this->subject,
"message" => $this->message,
"image" => $this->image,
"receiver_image" => $this->receiver_image,
"attachments" => $this->attachments,
"sizesOfAttachments" => $this->sizesOfAttachments,
"originalFileNames" => $this->originalFileNames,
"thread_id" => $this->thread_id,
"id_of_email" => $this->id_of_email,
];
event(new NewEmailReceivedEvent($NewEmailReceivedRequest));
return $NewEmailReceivedRequest;
}

/**
* Get the mail representation of the notification.
*
* @param  mixed  $notifiable
* @return IlluminateNotificationsMessagesMailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject("New email from ".$this->sender_type)
->greeting("Hello!")
->markdown("mails.NewEmailReceived" , ["recipient_name" => $this->receiver_name , "subject" => $this->subject , "mailMessage" => str_limit($this->message, 50) , "avatar" => $this->image]);
}


/**
* Get the array representation of the notification.
*
* @param  mixed  $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}

Estaría muy agradecido si alguien pudiera ayudarme en esto.

Respuestas

0 para la respuesta № 1

Parece tu notifications relación en su User objeto todavía referencias NotificationsForAdmin.

Si no especifica la tabla para un modelo, la tabla se genera automáticamente como una cadena snake_case del nombre del modelo. En el caso de NotificationsForAdmin esto se convierte en notification_for_admins.

Agregar la propiedad pública $table para usted NotificationsForAdmin con el nombre de la tabla donde se almacenan sus notificaciones como el valor. Esto debería solucionar tu problema.