1

I have a query that gets all the message between two id (user_id and to_user_id). I want to select all the query all the message of user in the two tables.

I have already made two where and it doesn't seem to work. It is just returning null.

  $last_message = DB::table('messages')
                  ->select('content')
                  ->where('user_id','=',Auth::user()->id)
                  ->where('to_user_id','=',Auth::user()->id)
                  ->orderBy('updated_at', 'desc')
                  ->first();

I expect the output of all the message of user

1 Answer 1

1

You should check on this Auth::user()->id, to see if it has a value or not. Also check on the datatype between table field and data source in query builder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.