php - dompdf not loading data vo view Laravel -
i'm trying convert html page pdf using dompdf wrapper in laravel. if show html page, informations database displayed on page, when try convert pdf have empty div tags without values database.
this code converting pdf:
public function viewuserorderdetails($id){ $user = user::find($id); $pdf = pdf::loadview('userorderdetails',['user' => $user]); return $pdf->stream("index.pdf"); }
and route function:
route::post('/userorderdetails/{id}',[ 'uses' => 'showallorders@viewuserorderdetails', 'as' => 'orderdetail', ]);
view sample code:
<div class="container"> <form class="form-horizontal" method="post"> <fieldset> <div class="col-lg-12 form-group margin50"> <label class="col-lg-2" for="name">user</label> <div class="col-lg-4"> <input type="hidden" name="_token" value="{{ csrf_token() }}"> <input type="text" id="name" name="name" placeholder="" class="form-control name" value="{{ $user->name }}" readonly> {{ csrf_field() }} </div> </div> <div class=" col-lg-12 form-group"> <label class="col-lg-2" for="producttype">orders</label> <div class="col-lg-4"> @foreach($user->orders $order) <input type="text" placeholder="" class="form-control name" value="{{ $order->order_name }}" readonly> @endforeach </div> </div> <div class="col-lg-12 form-group"> <label class="col-lg-2" for="manufacturer">price</label> <div class="col-lg-4"> @foreach($user->orders $order) <input type="text" placeholder="" class="form-control name" value="{{ $order->cena }}" readonly> @endforeach </div> </div> </div> </form>
also if try change $pdf = pdf::loadview('userorderdetails',['user' => $user]);
$pdf = pdf::loadview('userorderdetails',compact('user'));
gives me user not found error
any ideas?
Comments
Post a Comment