Not sending the proper object data to Pusher

蹲街弑〆低调 提交于 2019-12-25 10:57:11

问题


I dont know why the name is not included when broadcasting the event. But it is included in the return $message
Here is my Laravel's MessageController.

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Message;
use Illuminate\Support\Facades\Auth;
use App\Events\Chat;

class MessageController extends Controller
{
    public function create(Request $request){
        $message = new Message;
        $message->channel = $request->channel_id;
        $message->by = Auth::user()->id;
        $message->body = $request->message;

        $message->save();
        $message->name = "Clyde Santiago"; //This it the inserted data to the object
        event(new Chat($message)); //sends `message` object to Pusher but not including the `name`
        return $message //returns `message` object including the `name`
    }
}

来源:https://stackoverflow.com/questions/45326866/not-sending-the-proper-object-data-to-pusher

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!