Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class App\Models\User contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Myckhel\ChatSystem\Contracts\ChatEventMaker::chatEventMakers) #34

Closed
soumsena opened this issue Sep 11, 2021 · 7 comments

Comments

@soumsena
Copy link

Hello how are you???
I tried to implement the
* Myckhel\ChatSystem\Contracts\ChatEventMaker contract, in User Model, but I got an error
* Class App\Models\User contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Myckhel\ChatSystem\Contracts\ChatEventMaker::chatEventMakers); How can i fix that???
* I noticed in the API that we need 3 variables (name, email and password) to connect, but I only use 2 variables (username and password).
* how i want to handle this too???
* I also tried ChatSystem Broadcast Events;

var current_username = "{{ Auth::user()->username }}";
var current_user = "{{ Auth::user()}}";
var userid = "{{ Auth::id() }}";

Echo.private(message-event.user+userid)
.listen('message', (event) => {
console.log(event)
})
I got Error
[01:12:34] - 9BEdhJIOfQvhZG32AAAE could not be authenticated to private-message-event.user.9
{
"message": "Myckhel\ChatSystem\Broadcasting\Chat\UserMessageChannel::join(): Argument #2 ($messagesUser) must be of type Myckhel\ChatSystem\Broadcasting\Chat\User, string given, called in /var/www/eglise.local/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php on line 279",
"exception": "TypeError",
"file": "/var/www/eglise.local/vendor/myckhel/laravel-chat-system/src/Broadcasting/Chat/UserMessageChannel.php",
can you help me solve his errors please? Thank you!!!!!!!

@myckhel
Copy link
Collaborator

myckhel commented Sep 11, 2021

  • Does your user model looks like this
use Myckhel\ChatSystem\Traits\Message\HasMessage;
use Myckhel\ChatSystem\Traits\ChatEvent\CanMakeChatEvent;
use Myckhel\ChatSystem\Contracts\ChatEventMaker

class User extends Authenticatable implements ChatEventMaker
{
   use HasMessage, CanMakeChatEvent;
...

Checkout https://github.com/myckhel/chat-system-example/blob/53753dfdb6b8cce95b5cc27937a8fe57dabba2b5/app/Models/User.php#L15

  • Does using 2 variables gives you errors?
  • I think your broadcast routes must use authentication middleware
    E.g
 Broadcast::routes(['middleware' => ['auth:sanctum'], 'prefix' => 'api']);

See https://github.com/myckhel/chat-system-example/blob/53753dfdb6b8cce95b5cc27937a8fe57dabba2b5/app/Providers/BroadcastServiceProvider.php#L18

myckhel added a commit that referenced this issue Sep 11, 2021
@soumsena
Copy link
Author

Hi Thx for your help, i did implement the Myckhel\ChatSystem\Contracts\ChatEventMaker contract, in User Model; but the ChatSystem Broadcast Events does not work, when i modified both files, it show other error :
[19:17:05] - Preparing authentication request to: http://localhost:80
[19:17:05] - Sending auth request to: http://localhost:80/broadcasting/auth

⚠ [19:17:12] - -OwJ5yJ7_LU-TOUDAAAC could not be authenticated to private-message-event.user.9
{
"message": "Undefined variable $messageUser",
"exception": "ErrorException",
"file": "/var/www/eglise.local/vendor/myckhel/laravel-chat-system/src/Broadcasting/Chat/UserMessageChannel.php",
, Any idea???

I looked in your file chat-system-example, is very detailed, but it's in React or I'm null in React.
I can have an example in VUEJS please ???
thank you very much for your help

@myckhel
Copy link
Collaborator

myckhel commented Sep 12, 2021

I cannot provide example in Vue for now but feel free to ask for assistance on an challenges you might be facing

@soumsena
Copy link
Author

Hi, how are you doing??? I tried. Thanks a lot for your help; I still have an error
"Undefined variable $messageUser" when i use that

Echo.private(message-event.user.{{Auth::id()}})
.listen('message', (event) => {
console.log(event)
})

⚠ [19:16:41] - 2t5Qjv6H0aEAdFr8AAAM could not be authenticated to private-message-event.user.9
{
"message": "Undefined variable $messageUser",

I haven't had a solution yet,

@soumsena
Copy link
Author

I am using the vue-advanced-chat package like the Frontend.
here is an example of my component
chat.txt
Now i have to do the backend. sorry help me please

@myckhel
Copy link
Collaborator

myckhel commented Sep 15, 2021

What exactly did you want me to help you with?

@myckhel
Copy link
Collaborator

myckhel commented Dec 22, 2021

Feel free to re-open when needed.

@myckhel myckhel closed this as completed Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants