i am submitting a search form and based on the posted values results are fetched from DB and shown on the result page. I want to download these results in a PDF file. I configured Dompdf and its downloading PDF with some test data as below :
public function Genderate_PDF()
{
$data = ['title' => 'some title'];
$pdf = PDF::loadView('pdf', $data);
return $pdf->download('mypdf.pdf');
}
but in my scenario instead of loading the pdf view I have to show results in a page and then export that page results to PDF on a button click( Export PDF). Can someone please guide me how can i achieve that
EDIT::
Below is the search result posted to view that i need to export as PDF
public function search(Request $request){
$result = \DB::table('matromonial_data');
if ($request->has('gender')) {
$result->where('gender', $request->input('gender'));
}
if ($request->has('age_from') && $request->has('age_to')) {
$datefrom=$request->input('age_from');
$dateto=$request->input('age_to');
$result->where(function($query) use ($datefrom,$dateto){
$query->whereBetween('age',array($datefrom,$dateto)) ;
});
}
if ($request->has('height_from') && $request->has('height_to')) {
$height_from=$request->input('height_from');
$height_to=$request->input('height_to');
$result->where(function($query) use ($height_from,$height_to){
$query->whereBetween('height',array($height_from,$height_to)) ;
});
}
if ($request->has('religion')) {
$result->whereIn('religion', $request->input('religion'));
}
if ($request->has('cast')) {
$result->whereIn('cast', $request->input('cast'));
}
if ($request->has('mother_tongue')) {
$result->whereIn('mother_tongue', $request->input('mother_tongue'));
}
if ($request->has('maritial_status')) {
$result->whereIn('maritial_status', $request->input('maritial_status'));
}
if ($request->has('country')) {
$result->whereIn('country', $request->input('country'));
}
if ($request->has('city')) {
$result->whereIn('city', $request->input('city'));
}
if ($request->has('profession')) {
$result->whereIn('profession', $request->input('profession'));
}
if ($request->has('education')) {
$result->whereIn('education', $request->input('education'));
}
if ($request->has('income')) {
$result->whereIn('income', $request->input('income'));
}
if ($request->has('keywords')) {
$result->where('keywords', 'like','%' . $request->input('keywords') .'%');
}
if ($request->has('smoking_status')) {
$result->where('smoking_status', $request->input('smoking_status'));
}
if ($request->has('drinking_status')) {
$result->where('drinking_status', $request->input('drinking_status'));
}
$data['result_set']=$result->get();
return view('admin/search_result', $data);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire