notifications||markAsRead 方法 undefined
notificationsController 代码如下.
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
class NotificationsController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
// 获取登录用户的所有通知
$notifications = Auth::user()->notifications()->paginate(20);
// 标记为已读,未读数量清零
Auth::user()->markAsRead();
return view('notifications.index', compact('notifications'));
}
很莫名,不知道哪里出问题了,求大神指点迷津
推荐文章: