get a list of users who I have contacted or they have contacted me

  laravel, php

I’m working on messaging application (internal) and I would like to get a list of users who have contacted or I have contacted, just like facebook inbox ( on the left you see a list of users who contacted you or you have contacted )

I tried a lot but I couldn’t success, what kind of relations I should use to get what I’m looking for, This is my migration

Schema::create('messages', function (Blueprint $table) {



Source: Ask PHP