Laravel 中的广播和 websocket 问题

Problem with broadcasting and websocket in Laravel

我不明白它在哪里阻塞。如果我将 update() 替换为 create() 方法,它会起作用,或者如果我删除广播,则更新会起作用。如何随播更新?

Call to a member function load() on bool

public function SendToMarket(Request $request, $id)
{
    $card = auth()->user()->cards()->findOrFail($id)->update([
            'market_id' => $request["_market"],
            'borderStyle_id' => $request["_borderStyle"],
            'price' => $request["_price"]
        ]
    );

    $notification = array(
        'message' => 'Card Send to market Successfully !',
        'alert-type' => 'warning'
    );

    broadcast(new FetchCardEvent($card->load('user')))->toOthers();

    return redirect()->route('user.cards')->with($notification);
}

update() 不 return 模态实例。相反,它将 return a Boolean.

使用 firstOrFail() 检索卡片后,您应该单独更新它。

public function SendToMarket(Request $request, $id) {
    $card = auth()->user()->cards()->findOrFail($id);

    $card->update([
        'market_id' => $request["_market"],
        'borderStyle_id' => $request["_borderStyle"],
        'price' => $request["_price"]
    ]);

    $notification = array(
        'message' => 'Card Send to market Successfully !',
        'alert-type' => 'warning'
    );

    broadcast(new FetchCardEvent($card->load('user')))->toOthers();

    return redirect()->route('user.cards')->with($notification);
}