Unable to save data to database (Ratchet)?

I wrote a simple chat with Ratchet
public function onMessage(ConnectionInterface $from, $msg)
{
DB::table('chat')->insert([
 'visa_order_id' => 1,
 'user_id' => 1,
 'text' => 1,
]);
 }

Try a test save data but leaves the error:
An error has occurred: A facade root has not been set.
The Connection 53 has disconnected
July 2nd 19 at 18:15
1 answer
July 2nd 19 at 18:17
public function onMessage(ConnectionInterface $from, $msg) {

$numRecv = count($this->clients) - 1;
echo sprintf('Connection %d sending message "%s" to %d other connection%s' . "\n"
, $from->resourceId, $msg, $numRecv, $numRecv == 1 ? ": 's');

foreach ($this->clients as $client) {
$client->send($this->response->make($msg));
$ms= json_decode($msg);
$ms= (object)$ms;
\App\Messages::create(['body'=>$session_name,'user_id'=>$ms->client->data->user_id,'chat_id'=>1]);
}
}
I have so works

Find more questions by tags SocketsLaravelPHP