我不知道为什么广播活动时不包括name
。但它包含在return $message
中
这是我的Laravel' 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`
}
}