cmgmyr / laravel-messenger

Simple user messaging package for Laravel
MIT License
2.45k stars 514 forks source link

Cannot use if users don't have a name attribute #44

Closed Aryess closed 9 years ago

Aryess commented 9 years ago

Hi,

To make it short, my users don't have a name field, but two fields (first + last names). Even with an alias in the model (getNameAttribute) it doesn't work as laravel seems to be looking for it directly in the database (SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.name' in 'field list') I think it should either have an interface on Messagable, or allow to choose another one in the config.

cmgmyr commented 9 years ago

Hey, You can override the default method variable here - https://github.com/cmgmyr/laravel-messenger/blob/master/src/Cmgmyr/Messenger/Models/Thread.php#L218 buy doing something like this: $thread->participantsString(null, ['first_name', 'last_name']). This was changed in #33 to match up with Laravel's default user table structure. I use first_name and last_name myself. Please let me know if you have any other questions.

Aryess commented 9 years ago

Perfect thanks :thumbsup: