Я могу запускать события из консоли отладки Pusher, но Laravel 5.2 не запускает их - PullRequest
0 голосов
/ 20 сентября 2019

Я могу запускать фиктивные события из консоли отладки Pusher, и моя клиентская часть может их забрать.Но когда я пытаюсь запустить событие из моего UserController, кажется, ничего не происходит.

Вот мой класс Event

<?php

namespace App\Events;

use App\Events\Event;
use App\Player;
use App\Product;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class NewPurchase extends Event implements ShouldBroadcast
{
    use SerializesModels;

    public $product;

    /**
     * Create a new event instance.
     *
     * @param Product $product
     * @return void
     */
    public function __construct(Product $product)
    {
        $this->product = $product;
    }

    /**
     * Get the channels the event should be broadcast on.
     *
     * @return array
     */
    public function broadcastOn()
    {
        return [Player::where('user_id', $this->product->seller_id)->first()->group_id];
    }
}

Вот мой слушатель, у которого ничего нет, потому что я хочу, чтобы все было на стороне клиента процесса

<?php

namespace App\Listeners;

use App\Events\NewPurchase;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class NewPurchaseListener implements ShouldQueue
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  NewPurchase  $event
     * @return void
     */
    public function handle(NewPurchase $event)
    {
        //
    }
}

Здесьмой .env

BROADCAST_DRIVER=pusher
PUSHER_APP_ID=858577
PUSHER_APP_KEY=ec160cc0a1ca15e463f4
PUSHER_APP_SECRET=
QUEUE_DRIVER=sync 

Вот мой провайдер службы событий

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\NewPurchase' => [
            'App\Listeners\NewPurchaseListener',
        ],
    ];

А вот где происходит событие

 Event::fire(new NewPurchase($product));
...