Alguna ayuda ?
Código PHP:
Ver original
Route::get('chat', function(){ // Get the number of days to show data for, with a default of 7 $usr1 = 121; $usr2 = 123; $output = []; /***Obtener conversacion 121 y 123**/ $messageuser = MessageUser::with('conversaciones')->orderBy('created_at')->get(); foreach($messageuser as $msj){ if(($msj->id_emisor == $usr1)&&($msj->id_receptor == $usr2)){ $usuario1 = User::find($usr1); foreach($msj->conversaciones as $conv){ echo $usuario1->name; echo $conv->contenido; echo $conv->created_at ; } } if(($msj->id_emisor == $usr2)&&($msj->id_receptor == $usr1)){ $usuario2= User::find($usr2); foreach($msj->conversaciones as $conv){ echo $usuario2->name; echo $conv->contenido ; echo $conv->created_at ; } } } });