درود فراوان بنده می خوام وقتی کاربر کامنت ثبت کرد که کامنت در در صفحه سینگل محصول قرار دارد.
یک نوتیفیکیشن برای برای ادمین ارسال شود اما موقع ارسال به این ارور بر می خورم.
BadMethodCallException
Call to undefined method Illuminate\Database\Eloquent\Builder::routeNotificationFor()
این کد کنترلر مربوط به ثبت کامنت
public function comment(Request $request,Comment $comment)
{
$data = $request->validate([
'commentable_id' => 'required',
'commentable_type' => 'required',
'description' => 'required',
'parent_id' => 'required',
]);
auth()->user()->comments()->create($data);
Mail::to($request->user()->email)->send(new CommentSend($request, $request->user()->name));
//Notification For Admin
Notification::send(User::query()->where('is_supper_user',1),new CommentAnnouncementForAdmin($comment));
alert()->message('پس از تایید در سایت نمایش داده خواهد شد', 'دیدگاه شما با موفقیت ثبت شد')->autoclose('4000');
return back();
}
اینم notification
protected Comment $comment;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Comment $comment)
{
$this->comment = $comment;
}
public function via($notifiable)
{
return ['database'];
}
public function toDatabase($notifiable)
{
return [
'description'=>$this->comment->description
];
}
اینم روتی که برای نوتیفیکیشن در پنل ادمین ساختم
Route::get('announcementnotification','App\Http\Controllers\Admin\CommentAnnouncementForAdminController@AnnouncementComment');شاید پاسخ شما همینجا باشد