chat application with laravel

本秂侑毒 提交于 2020-06-29 04:29:18

问题


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

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