0
晚安!與Laravel創建聊天
我設法顯示有關用戶,並與下面的代碼
Route::get('chat', function(){
// Get the number of days to show data for, with a default of 7
$usr1 = 121;
$usr2 = 123;
/***Obtener conversacion 121 y 123**/
$messageuser = MessageUser::with('conversaciones')->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;
}
}
if(($msj->id_emisor == $usr2)&&($msj->id_receptor == $usr1)){
$usuario2= User::find($usr2);
foreach($msj->conversaciones as $conv){
echo $usuario2->name;
echo $conv->contenido;
}
}
}
});
信息的消息的內容現在,我需要加入這個兩個條件爲數組發送結果查看,我不知道如何創建這個數組,有人會善意幫助我呢?