/**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($personId, $childId)
 {
     $person = CriminalHistory::find($personId);
     if ($childId) {
         $datachild = DataChild::find($childId)->delete();
         return $person;
     } else {
         return null;
     }
 }
 public function savePhotoPerson($id)
 {
     $photo = CriminalHistory::find($id);
     $uuid = Uuid::uuid4();
     $public_path = "photo/person/{$id}/";
     $destination_path = public_path($public_path);
     //$jpg = ".jpg";
     Input::file('file')->move($destination_path, $uuid);
     $photo->photo = "/photo/person/{$id}/{$uuid}";
     $photo->save();
     return $photo;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($personId, $officeId)
 {
     $person = CriminalHistory::find($personId);
     if ($officeId) {
         $addressoffice = AddressOffice::find($officeId)->delete();
         return $person;
     } else {
         return null;
     }
 }
 public function savePhotoPerson($id)
 {
     // return $id;
     $photo = CriminalHistory::find($id);
     $uuid = Uuid::uuid4();
     $public_path = "photo/person_crime/{$id}/";
     $destination_path = public_path($public_path);
     //$jpg = ".jpg";
     $ext = Input::file('file')->getClientOriginalExtension();
     Input::file('file')->move($destination_path, "{$uuid}.{$ext}");
     $photo->photo = "/photo/person_crime/{$id}/{$uuid}.{$ext}";
     $photo->save();
     return $photo;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($caseId, $personId)
 {
     /* @var Datacase $case */
     $case = DataCase::find($caseId);
     $person = CriminalHistory::find($personId);
     if ($person) {
         $case->criminalhistory()->detach($person->id);
         return $case;
     } else {
         return null;
     }
 }
 public function generatedPdfPerson($id)
 {
     $criminalhistory = CriminalHistory::find($id);
     $idcard = $criminalhistory->idcard;
     $datacasesPerson = CriminalHistory::with('datacase', 'addresspresent', 'addressoriginal', 'datafather', 'datamother', 'dataspouse', 'datachild', 'addressoffice', 'datacase.vehicle', 'datacase.weapon')->where(function ($q) use($idcard) {
         return $q->where('idcard', '=', "{$idcard}");
     })->get();
     $criminalhistory = CriminalHistory::with('datacase', 'addresspresent', 'addressoriginal', 'datafather', 'datamother', 'dataspouse', 'datachild', 'addressoffice', 'datacase.vehicle', 'datacase.weapon')->find($id);
     Event::fire(new PrintPdfDataPersonCrimeEvent($criminalhistory));
     //return $dataperson;
     //$pdf = \App::make('mpdf.wrapper',['ภาษา','ขนาดการดาษ-L=แนวนอน ไม่- แนวตั้ง','','',ขอบซ้ายกระดาษ,ขอบขวากระดาษ,ขอบขนกระดาษ,ขอบล่างกระดาษ,ระยะ title,ระยะ footter]);
     //return $datacase;
     $pdf = \App::make('mpdf.wrapper', ['th', 'A4', '', '', 20, 15, 20, 25, 10, 10]);
     $pdf->setTitle("export");
     //$pdf->SetHeader('|{PAGENO}/{nbpg}|สำนักงานตำรวจตรวจคนเข้าเมือง จังหวัด เชียงราย');
     // $pdf->SetFooter('พิมพ์เมื่อ วัน {DATE D} ที่ {DATE j-m-Y} เวลา {DATE H:i:s}  ');
     $pdf->SetHeader('
     <table width="100%" style="vertical-align: bottom; font-family: TH SarabunPSK; font-size: 14pt; color: #000000; font-weight: bold; font-style: italic;"><tr>
     <td width="20%"></td>
     <td width="30%" style="text-align: right; ">{PAGENO}</td>
     <td width="55%" style="text-align: right; "> ตรวจคนเข้าเมืองจังหวัดเชียงราย</td>
     </tr></table>
     ');
     $user = Auth::user();
     $rank = $user->rank->rank;
     \Carbon\Carbon::setLocale('th');
     setlocale(LC_TIME, 'th_TH');
     $date = \Carbon\Carbon::now();
     $daymonth = $date->formatLocalized('%d/%m/');
     $year = $date->year + 543;
     $pdf->SetFooter("\n        <table width='100%' style='vertical-align: bottom; font-family: garuda; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;'><tr>\n      \n        <td width='45%'>พิมพ์โดย {$rank} {$user->name_police} {$user->surname_police}</td>\n        <td width='55%' style='text-align: right; '>พิมพ์เมื่อ {$daymonth}{$year}</td>\n        </tr></table>\n        ");
     $pdf->SetWatermarkText("");
     $pdf->SetDisplayMode('fullpage');
     $html = view('PDF.personOne')->with('dataperson', $criminalhistory)->with('datacases', $datacasesPerson)->render();
     //return $html;
     $pdf->WriteHTML($html);
     $pdf->stream();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($personId, $employeeId)
 {
     $person = CriminalHistory::find($personId);
     if ($employeeId) {
         $employee = Employee::find($employeeId)->delete();
         return $person;
     } else {
         return null;
     }
 }