Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
parámetro de pase de empujador en laravel broadcastAs

hola tengo este codigo js

 var pusher = new Pusher('my pusher key', { cluster: 'ap2' }); var channel = pusher.subscribe('my-channel'); channel.bind('my-event', function(data) { console.log(data); });

y este es mi codigo laravel

 protected $pos_invoice; public function __construct($pos_invoice) { $this->pos_invoice = $pos_invoice; } public function broadcastOn() { return new Channel('my-channel'); } public function broadcastAs() { return 'my-event'; }

y este es el codigo de llamada

 return event( new \App\Events\New_pos_online_order_event('aa'));

ahora el codigo

 channel.bind('my-event', function(data) { console.log(data); });

siempre regresa [] en la consola, así que probé esto

 public function broadcastAs() { return 'my-event.'.$this->pos_invoice; }

y esto

 public function broadcastOn() { return new Channel('my-channel'.'asdfasdf'); }

cuando cambio algo

 public function broadcastOn() { return 'my-channel'; } public function broadcastAs() { return 'my-event'; }

el código no funciona y no devuelve nada en la consola, entonces, ¿cómo puedo pasar el parámetro en pusher y laravel con js gracias?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Necesitas definir la función broadcastWith

 ** * Get the data to broadcast. * * @return array */ public function broadcastWith() { return ['pos_invoice' => $this->pos_invoice]; }

Recibirá la matriz en los datos de la función de enlace.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!