I made a pdf creator link in my laravel app. But when i click on my link to the PDF i get a 404. This is my code:
Link to the customer:
<a href="/mvs/mvs/public/admin/kunden/pdf/">Button html</a>
Route:
Route::get('/mvs/mvs/public/admin/kunden/pdf/{id}', 'DynamicPDFController@get_customer_data');
PDF Controller:
use Illuminate\Http\Request;
use DB;
use PDF;
class DynamicPDFController extends Controller
{
function index()
{
$customer_data = $this->get_customer_data();
$finance_data = $this->get_finance_data();
return view('dynamic_pdf')->with('customer_data', $customer_data);
}
function get_customer_data($id)
{
//Handle PDF stuff here
$customer_data = DB::table('kundens')
->where('id', '=', $id)
->firstOrFail();
//Save PDF link to customer here
$customer_data->save();
return $customer_data;
}
function pdf()
{
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($this->convert_customer_data_to_html());
return $pdf->stream();
}
function convert_customer_data_to_html()
{
$customer_data = $this->get_customer_data();
$output = '
<h3 align="center">Angebot</h3>
<table width="100%" style="border-collapse: collapse; border: 0px;">
<tr>
<th style="border: 1px solid; padding:12px;" width="20%">Vorname</th>
<th style="border: 1px solid; padding:12px;" width="30%">Nachname</th>
<th style="border: 1px solid; padding:12px;" width="15%">Stadt</th>
<th style="border: 1px solid; padding:12px;" width="15%">PLZ</th>
';
foreach($customer_data as $kunden) { $output .= ' '.$kunden->vorname.' '.$kunden->nachname.' '.$kunden->wohnort.' '.$kunden->plz.'
When i now click on the link "Button HTML" i get a 404 error page. But i dont know why :(
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire