未定义的方法 'notify'。智能手机(1013)
Undefined method 'notify'. intelephense(1013)
我有这个安宁的代码:
auth()->user()->notify(new TestNotification($oneParam, $twoParam));
我的auth()->user()
return用户登录如下:
App\Models\User\User {#1094 ▼
+timestamps: false
#fillable: array:8 [▶]
#hidden: array:1 [▶]
#appends: array:1 [▶]
#connection: "mysql"
#table: "users"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:13 [▶]
#original: array:13 [▶]
#changes: []
#casts: []
#classCastCache: []
#dates: []
#dateFormat: null
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
#visible: []
#guarded: array:1 [▶]
#rememberTokenName: "remember_token"
#accessToken: Laravel\Passport\Token {#1055 ▶}
}
我在 User Model
中有 use Notifiable;
特征和 use Illuminate\Notifications\Notifiable;
导入。
VSC 扩展:PHPIntelephense v1.7.1
PHP7.4.9
Laravel 框架 8.52.0
使用通知外观而不是方法。
auth()->user()->notify(new TestNotification($oneParam, $twoParam));
替换为:
Notification::send(auth()->user(), new TestNotification($oneParam, $twoParam));
我有这个安宁的代码:
auth()->user()->notify(new TestNotification($oneParam, $twoParam));
我的auth()->user()
return用户登录如下:
App\Models\User\User {#1094 ▼
+timestamps: false
#fillable: array:8 [▶]
#hidden: array:1 [▶]
#appends: array:1 [▶]
#connection: "mysql"
#table: "users"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:13 [▶]
#original: array:13 [▶]
#changes: []
#casts: []
#classCastCache: []
#dates: []
#dateFormat: null
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
#visible: []
#guarded: array:1 [▶]
#rememberTokenName: "remember_token"
#accessToken: Laravel\Passport\Token {#1055 ▶}
}
我在 User Model
中有 use Notifiable;
特征和 use Illuminate\Notifications\Notifiable;
导入。
VSC 扩展:PHPIntelephense v1.7.1 PHP7.4.9 Laravel 框架 8.52.0
使用通知外观而不是方法。
auth()->user()->notify(new TestNotification($oneParam, $twoParam));
替换为:
Notification::send(auth()->user(), new TestNotification($oneParam, $twoParam));