zeynab
3 سال پیش توسط zeynab مطرح شد
1 پاسخ

pusher

سلام ،
با استفاده از pusher برنامه زیر نوشتم . اما به درستی کار نمیکنه و خطا هم ندارد .

  • قسمت مربوط به اجرای event

    $id = '2';
    $notification = 'test ....';
    event(new \App\Events\UserShowNotificationEvent($notification,$id));
  • کد های event

    class UserShowNotificationEvent implements ShouldBroadcast
    {
    use Dispatchable, InteractsWithSockets, SerializesModels;
    
    public $notification;
    public $id;
    
    /**
    * Create a new event instance.
    *
    * @param $notification
    * @param $id
    */
    public function __construct($notification,$id)
    {
    $this->notification = $notification ;
    $this->id = $id ;
    
    }
    
    /**
    * Get the channels the event should broadcast on.
    *
    * @return \Illuminate\Broadcasting\Channel|array
    */
    public function broadcastOn()
    {
    return new PrivateChannel('notify-send-user.'.$this->id); 
    }
    }
  • فایل channels
    توضیح تصویر رو وارد کنید

  • فایل js
    توضیح تصویر رو وارد کنید

اگر در این قسمت

return new PrivateChannel('notify-send-user.'.$this->id);

به جای this->id کلمه مثلا user بنویسم . برنامه به درستی اجرا میشود و اطلاعات در کنسول نمایش میدهد . اما زمانی که id ارسال میکنم برنامه اجرا نمیشود

اگر کسی اطلاع داره مشکل از کجاست ممنون میشم راهنمایی کنید .


ثبت پرسش جدید
zeynab
تخصص : برنامه نویس تحت وب
@sahelz74 3 سال پیش آپدیت شد
0

سلام مجدد
کسی جواب سوال بالا نمیدونه ؟؟


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام