A
A
Andrey_Pechurevich2020-12-22 23:29:01
JSON
Andrey_Pechurevich, 2020-12-22 23:29:01

How to fix Malformed UTF-8 characters, possibly incorrectly encoded error when passing data to Laravel event?

There is the following code, the purpose of which is to pass data to the event.

$result = Message::create($request->all());
            event(new \App\Events\StrangeEvent($result));


Inside the event is the following code:
class StrangeEvent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;
    public $message;
    
    public function __construct($messages)
    {
        $this->message = $messages;
    }

    public function broadcastOn()
    {
        return ['channel'];
    }
}


As a result, this error always appears. Attempts to decode to UTF-8 using mb_convert_encoding were unsuccessful.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question