lundi 4 juillet 2016

How to generate PDF For the Active View?

I have a search box when user input roll no, it returns the specific student result. I want to generate PDF of that searched data, that data is in table. enter image description here Main Question : I want to generate PDF for the result of student who has searched for his/her data, so how to generate PDF for that current student result.

Print/PDF Generator Button:

 <a href="{!! url('/getPDF') !!}">Print</a> 

PDFController:

class PDFController extends Controller
{
    public function getPDF(Request $request){
            // I want some code here to get the current student result so that I can generate pdf for the current student
            $pdf = PDF::loadView('results.single');
            return $pdf->stream('result.pdf');
    }
}

SearchController:

class ResultsSearchController extends Controller
{
    public function search()
    {
        $keyword = Input::get('keyword');
        $row = Student::where('rollno',$keyword)->first();
        $rollno = $row['rollno'];
        if($keyword == $rollno){
            return View::make('results.single')
            ->with('search',Student::where('rollno',$keyword)
            ->get())->with('keyword',$keyword);
        }else{
            return view('errors.404');
        }
    }
}

Routes.php:

Route::get('/getPDF', 'PDFController@getPDF');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire