public function saveinspectordetails($id)
 {
     $rules = [];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $vehicle = Vehicle::findOrFail($id);
         $vehicle->inspectordetails()->update(Input::except('_token', '_method', 'medrep'));
         //Event::fire('vehicle.inspected', array($vehicle));
         return Redirect::to('vehiclesinspection')->with('success', 'Vehicle Roadworthiness Report Saved Successfully');
     } else {
         return Redirect::to('vehicle/' . $id . '/report')->withErrors($validator)->withInput();
     }
 }
 public function download($id, $action = null)
 {
     $vehicle = Vehicle::findOrFail($id);
     $html = "<center> " . "<img src=" . URL::asset('assets/images/logoo.png') . "></center>" . "<br>" . "<center style='font-size:20px'>EAST AFRICA AUTOMOBILE SERVICE Co.,LTD" . "<br>" . "TEL : 046-205-7611  Website : http://www.eaa-s.jp" . "<br>" . "FAX : 046-205-7610  Email : info@eaa-s.jp" . "<br>" . "<p style='font-size:30px'><i>Certificate of Appraisal</i></p></center>" . "<br><b>Certificate Number: " . $vehicle->certificate->certno . "</b>" . "<br>" . "<br>" . "Date of Issue: " . $vehicle->certificate->updated_at . "<br>" . "Date of Appraisal: " . $vehicle->inspectordetails->updated_at . "<br>" . "<br>" . "<br>" . "Client: " . $vehicle->user->fullname . "<br>" . "Email: " . $vehicle->user->email . "<br>" . "Phone Number: " . $vehicle->user->phone . "<br>" . "<br>" . "<br>" . "We hereby certify that the vehicle, for which details are given below," . "has the following value at the time of appraisal in Japan" . "<br>" . "<br>" . "Make: " . $vehicle->make . "<br>" . "Model: " . $vehicle->model . "<br>" . "Engine Capacity (cc rating): " . $vehicle->enginecc . "<br>" . "Year of First Registration: " . $vehicle->yor . "<br>" . "Chassis Number: " . $vehicle->chasis . "<br>" . "Engine Number: " . $vehicle->engineno . "<br>" . "Inspected Mileage (Odometer Reading): " . $vehicle->mileage . "<br>" . "Inspected Date: " . $vehicle->inspection->updated_at . "<br>" . "<br>" . "<br>" . "Remarks: " . $vehicle->inspection->comment . "<br>" . "<br>" . "<br>" . "This appraisal for the vehicle was made in accordance with, and on the basis of the provisions set forth by" . " EAST AFRICA AUTOMOBILE SERVICES" . "<br>" . "<img src=" . URL::asset('assets/images/place.png') . ">" . "<br>" . "<img src=" . URL::asset('assets/images/sign.png') . ">" . "<br>" . "____________________________________________________________________________________________________________________________________________________ " . "<br>" . "THIS CERTIFICATE IS VALID FOR A PERIOD OF THREE(3) MONTHS FROM THE DATE OF ISSUE" . "<br>";
     if ($action == 'view') {
         return PDF::load($html, 'A4', 'portrait')->show();
     } else {
         return PDF::load($html, 'A4', 'portrait')->download($vehicle->certificate->certno);
     }
 }