1) Update chat.js file :-
We will update chat.js file with isTyping and notTyping functions. isTyping function we will call when user is typing something and notTyping function we will call when user is not typing anything.
And we will call notTyping function in sendMessage function after user sends the message.
2) Create Routes for isTyping and notTyping in web.php file with username parameter like below :-
Route::post('/chat/isTyping', 'ChatController@isTyping');
Route::post('/chat/notTyping', 'ChatController@notTyping');
3) Create isTyping and notTyping functions in ChatController :-
We will create isTyping and notTyping functions in ChatController. As stated earlier, isTyping function we will call when user is typing and notTyping function we will call when user is ideal.
In isTyping function, we will compare username who is typing and updates users table with 1 value for column 'user is typing'.
In notTyping function, we will compare username who is typing and updates users table with 0 value for column 'user is typing'.
4) Update Header Statement :-
Add below statement at the top of ChatController to include User model :-
use App\User;
To be continued in next video...
0 Comments