【问题标题】:Issue with Laravel NotificationsLaravel 通知问题
【发布时间】:2019-03-17 20:45:07
【问题描述】:

我对 Laravel 通知有疑问。我尝试向用户提供有关某事的通知,但 Laravel 找不到通知类。

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;    

class NotificationController extends Controller
{    

    public function getNot(Request $request)
    {
        $user = Auth::user();            

        $user->notify(new NewPost('a'));
    }
}

我还创建了一个名为NewPost.php 的通知,问题是:

找不到类“App\Http\Controllers\NewPost”

这个,所以在User模型中已经包含了Notificationsnotifiable.

【问题讨论】:

  • 请添加您的通知代码和与通知相关的型号代码。
  • 在我的用户模型中,只有使用 Notifable;

标签: laravel notifications


【解决方案1】:

在类定义之前添加use语句。

use Illuminate\Http\Request;
use Auth; 
use App\Notifications\NewPost;

我假设您由工匠创建通知,如果不是,请记住命名空间可能不同。

【讨论】:

  • 我是工匠制作的
  • 我仍然收到错误 Class 'App\Notification\NewPost' not found
  • 通知s 不是通知
  • 是的,这只是一个命名空间问题。
猜你喜欢
  • 2019-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多