I have developing the ticket system. First table data fetch and display the view page but reply result is showing the last records. How to solve this issue. Please support me.
Controller
$ticketdetails = TicketDetails::where('ticket_id', '=', $ticketID)
->orderBy('ticket_id', 'asc')->get();
if($ticketdetails->count()){
foreach ($ticketdetails as $ticketItem) {
$ticketID = $ticketItem->ticket_id;
$reply_check = Reply::where('reply_ticket_id', '=', $ticketID)->count();
if($reply_check!="")
{
$reply = Reply::where('reply_ticket_id', '=', $ticketID)->first();
}
} //Close foreach
} // Close if loop
return view('view-ticket',compact('data','ticketdetails','reply'));
View Page
if($ticketdetails->count())
@foreach($ticketdetails as $ticketdetails)
<p>{{$ticketdetails->ticket_details}}</p>
$replyid = $reply->reply_ticket_id;
$ticketdetailsid = $ticketdetails->ticket_id;
@php
if($replyid==$ticketdetailsid)
{
@endphp
<p>{{$reply->reply_ticket_comments}}</p>
@php
}
@endphp
@endforeach
@endif
Expecting View page- For example
Ticket Case : Printer not working
Reply:Restart Printer - this is first reply
Ticket Case : After restart same issue.
Reply:okay, we will check now -- this is second reply
Display For view page
Ticket Case : Printer not working
Reply:okay, we will check now -- this is second reply
Ticket Case : After restart same issue.
Reply:okay, we will check now -- this is second reply
Note:Ticket case data display is correct but reply data only showing the last record.