/ / Laravel通知ベーステーブルが見つかりません-mysql、laravel、通知、laravel-5.5、プッシャー

Laravel Notifications Base Tableが見つかりません-mysql、laravel、notifications、laravel-5.5、プッシャー

私はLaravelプロジェクトに取り組んでいます。これらのコマンドを実行して、通知テーブルを正常に作成しました。

php artisan notifications:table
php artisan migrate

すべてが完璧に進んでいた。 後で、 "notifications_for_admin"という名前のマイグレーションを使用してモデル名 "NotificationsForAdmin"を作成し、後でこのテーブルを垂下しました。いくつかの通知を生成しようとすると、このエラーが表示されますが、完璧なスキーマを使用したlaravel通知に必要なデータベースに通知テーブルがあるのか​​わかりません。エラーは:

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)

私の通知は:

<?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 [
//
];
}
}

これについて誰かが私を助けてくれれば、私は非常に感謝します。

回答:

回答№1は0

それはあなたのようです notifications あなたの関係 User オブジェクトはまだ参照しています NotificationsForAdmin.

モデルのテーブルを指定しない場合、テーブルはモデル名のsnake_case文字列として自動的に生成されます。の場合 NotificationsForAdmin これになります notification_for_admins.

パブリックプロパティを追加する $table あなたの NotificationsForAdmin 通知が値として格納されているテーブルの名前で。これで問題が解決するはずです。