Closed hamelraj89 closed 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()
.
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 into
conversations(
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()
??
Are you using Laravel 5.4?
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
@nahid ????
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);
}
`
SOLVED!. Used
public function __construct() { Talk::setAuthUserId(Auth::id()); }
In Laravel 5.4
@AdebsAlert @Pravinslk please install v2.2.0 and read the updated doc
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 ?