nahid / talk

Talk is a real-time users messaging and chatting system for Laravel.
MIT License
1.61k stars 327 forks source link

where need to set global auth id ? #48

Closed hamelraj89 closed 7 years ago

hamelraj89 commented 7 years ago

i have set id like this in MessageController Talk::setAuthUserId(Auth::id()); but when i send message error user_one cant be null it mens auth ID not inserting so do i want replace anywhere else ?

nahid commented 7 years ago

You can set it in Controller constructor. Yes you can replace it anywhere. even you can use directly auth user like this Talk::user(auth()->user()->id)->getInbox().

hamelraj89 commented 7 years ago

what i did is for my laravel project i installed using composer. when i try to send message i got error trying to get non object then i hanged my constructor in MessageController Talk::setAuthUserId(Auth::id()); like this then when i try to send message SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_one' cannot be null (SQL: insert intoconversations(user_one,user_two,status,updated_at,created_at) values (, 2, 1, 2017-04-01 04:56:11, 2017-04-01 04:56:11)) so somewhere else need to define auth id() ??

nahid commented 7 years ago

Are you using Laravel 5.4?

hamelraj89 commented 7 years ago

Laravel 5.3.... can you try with 5.3 and solve this issue ?? cause when i try with your https://github.com/nahid/talk-example Laravel sessions message not works and some errors in server so better if you solve this issue

hamelraj89 commented 7 years ago

@nahid ????

AdebsAlert commented 7 years ago

I am having the same issue...And I use Laravel 5.4. I am getting an error "Trying to get property of non-object". My codes `class MessageController extends Controller {

public function __construct()
{
    Talk::setAuthUserId(Auth::user()->id);
}

`

AdebsAlert commented 7 years ago

SOLVED!. Used public function __construct() { Talk::setAuthUserId(Auth::id()); } In Laravel 5.4

nahid commented 7 years ago

@AdebsAlert @Pravinslk please install v2.2.0 and read the updated doc