Skip to content

array_merge(): Expected parameter 2 to be an array #288

@carlomigueldy

Description

@carlomigueldy

image

Whenever I try to dispatch an event I get this error

<warning>PHP Warning:  array_merge(): Expected parameter 2 to be an array, null given in /home/carlomigueldy/playground/laravel-chat-app/api/vendor/pusher/pusher-php-server/src/Pusher.php on line 518</warning>

Can anyone help me out?

This is my MessageSent() class code

<?php

namespace App\Events;

use App\Models\ChatMessage;
use App\Models\User;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class MessageSent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $message;

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

    public function broadcastAs () {
        return 'message-sent';
    }

    // public function broadcastQueue () {
    //     return 'broadcastable';
    // }

    public function broadcastWith () {
        return [
            'text' => 'Awesome'
        ];
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('chat');
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions