问题
Hi i am working on a chat app with pusher
i need to get the Read After my message beside another users
i cant work with __invoke function i guess The problem is in the tuturial https://pusher.com/tutorials/read-receipts-laravel
i cant call this method ! relation between MessageDelivered Event and MessageDeliveredController
This is My issue
can any one to clarify this tuturial for me
thanks at all.
but i need to change the value of the statuse of the message in my chat app i mean read receipt in laravel and pusher
first value $chat->status ='sent'; next taht i need $chat->status ='delivered';
This is my chats table:
Schema::create('chats', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('user_id');
$table->text('message');
$table->timestamps();
});
with another column status that I migrated:
Schema::table('chats', function (Blueprint $table) {
$table->string('status');
});
class ChatController extends Controller
{
public function sendMessage(Request $request)
{
$chat = auth()->user()->messages()->create([
'message' => $request->message,
'status' => 'sent',
'user_id' => auth()->user()->id,
]);
broadcast(new ChatEvent($chat->load('user')))->toOthers();
return ['status' => 'success'];
}
}
class MessageDeliveredController extends Controller
{
public function __invoke(Chat $chat)
{
$chat->status = 'Delivered';
$chat->save();
broadcast(new MessageDelivered($chat));
}
}
来源:https://stackoverflow.com/questions/62498468/chat-application-with-laravel