问题
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