php - Creating a chat with Laravel -
good night !
i managed show information users , content of messages following code
route::get('chat', function(){ // number of days show data for, default of 7 $usr1 = 121; $usr2 = 123; /***obtener conversacion 121 y 123**/ $messageuser = messageuser::with('conversaciones')->get(); foreach($messageuser $msj){ if(($msj->id_emisor == $usr1)&&($msj->id_receptor == $usr2)){ $usuario1 = user::find($usr1); foreach($msj->conversaciones $conv){ echo $usuario1->name; echo $conv->contenido; } } if(($msj->id_emisor == $usr2)&&($msj->id_receptor == $usr1)){ $usuario2= user::find($usr2); foreach($msj->conversaciones $conv){ echo $usuario2->name; echo $conv->contenido; } } } });
now , need join 2 condition array send result view , don't know how create array , kind enough me ?
i try , use mvc architecture laravel designed in order organise code.
if variable values within messageuser model can query them without doing if statements. if want keep style of logic can loop using foreach within view , echo using double curly brackets echo results.
Comments
Post a Comment