Answer the question
In order to leave comments, you need to log in
How to correctly display the data of the user on which the button was pressed?
Good time of the day, guys, help me, I have an Invoices tab and in the database I created a connection between the invoices and the User, now when the person who clicked on the "button" is written to the Invoice table and the user's data is also recorded in the table with the help of links. Also, next to each user there are buttons "show invoice or download invoice".
After clicking on the button, an html invoice is generated in a separate page. and there I iterate over the foreatch array with data that is received from the database. and here is such a problem, if I have 2 invoices with different users, different data, then after clicking on the show invoice button, I get an invoice of 2 users, and not a specific invoice of the user who clicked on the button. How can I assign the data of one invoice for one user, so that everything is correct.
What if there was an invoice for user 1, then an invoice was formed with the data of user 1. etc.
here is the controller code:
public function invoiceView()
{
$this->user = Auth::User();
$pdf = PDF::loadView('pdf.invoice', ['data' => user::all()]);
return $pdf->stream('invoice.pdf');
}
public function invoiceDownload()
{
$this->user = Auth::User();
$pdf = PDF::loadView('pdf.invoice', ['data' => user::all()]);
return $pdf->download('invoice.pdf');
}
<center>Invoice</center>
@foreach ($data as $all)
<br>
ID USer:{{ $all['id'] }}<br>
Name:{{ $all['name'] }}<br>
Email:{{ $all['email'] }}<br>
Phone:{{ $all['phone'] }}<br>
@endforeach
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question