I work in an Simple message system between Users on my Site.
Every Message has an own unique ID
soo every user can see only the title
and text
from the current Message. I dont want code now an chat Message system just want display all Messages above the current message between the 2 Users in an Table.
Example how my Message looks like now:
Title:
Text/Message:
Reply Button
I want display now above all other Messages.
Default code:
Message from <span class="font-weight-600"></span> sent to <span class="font-weight-600"></span>
<div align="middle" class="form-group">
<font color="#b7b7b7">
</div>
<div class="form-group">
<label for="title">Subject:</label>
<input type="text" name="title" id="title" value="" class="formcreateproducttitle" readonly="">
</div>
<div class="form-group">
<label for="text">Message:</label>
<textarea name="text" class="formcreateproductdesc" style="resize:none" rows="8" cols="80" readonly=""></textarea>
</div>
<div class="form-group">
<center>
@if(Auth::user()->id == $message->To->id)
<a href="" class="btn btn-primary">Reply</a>
@elseif(Auth::user()->id == $message->From->id)
<a href="" class="btn btn-primary">Send another message to </a>
@endif
</center>
</div></font>
Code i want add before the default code:
<table class="table table-hover">
<thead>
<th>Title</th>
<th>text</th>
</thead>
<tbody>
@foreach($message as $messages)
<tr>
<td><?php $user = DB::table('messages')->where(['from'=> $message->from])->first(); echo $user->title; ?></td>
<td> </td>
@endforeach
</tr>
</tbody>
</table>
But now i see only the first Message between the users from DB in every Line, i think because ->first();
correct?
How i can Display all Messages between the 2 Users and not just the first? Or from the Sender only how i have do it in the code above better from both.
Many Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire