public function searchDataCase()
 {
     $start_date = Input::get('start_date');
     $end_date = Input::get('end_date');
     // return $start_date;
     $datacase = DataCase::with('criminalhistory', 'criminalhistory.nametitle')->whereBetween('date_case', [$start_date, $end_date])->get();
     $person = CriminalHistory::with('datacase', 'nametitle')->whereBetween('date', [$start_date, $end_date])->get();
     $person_general = GuestHistory::with('nametitle')->whereBetween('date', [$start_date, $end_date])->get();
     $data = [$person, $person_general, $datacase];
     return $data;
 }
 /**
  * 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;
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($caseId, $weaponId)
 {
     $datacase = DataCase::find($caseId);
     if ($weaponId) {
         $weapon = Weapon::find($weaponId)->delete();
         return $datacase;
     } else {
         return null;
     }
 }
 public function searchDataCase()
 {
     $start_date = Input::get('start_date');
     $end_date = Input::get('end_date');
     // return $start_date;
     $datacase = DataCase::with('criminalhistory', 'criminalhistory.nametitle')->whereBetween('date_case', [$start_date, $end_date])->get();
     $person = CriminalHistory::with('datacase', 'nametitle')->whereBetween('date', [$start_date, $end_date])->get();
     $person_general = GuestHistory::with('nametitle')->whereBetween('created_at', [$start_date, $end_date])->get();
     $data = [$person, $person_general, $datacase];
     $start_date = Input::get('start_date');
     $end_date = Input::get('end_date');
     // return $start_date;
     $datacase = DataCase::with('criminalhistory', 'criminalhistory.nametitle')->whereBetween('date_case', [$start_date, $end_date])->get();
     $person = CriminalHistory::with('datacase', 'nametitle')->whereBetween('date', [$start_date, $end_date])->get();
     $person_general = GuestHistory::with('nametitle')->whereBetween('created_at', [$start_date, $end_date])->get();
     $data = [$person, $person_general, $datacase];
     $pdf = \App::make('mpdf.wrapper', ['th', 'A4', '', '', 20, 15, 20, 25, 10, 10]);
     $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%"><img src="img/police.jpg" width="20" height="20"></td>
     <td width="30%" style="text-align: right; ">{PAGENO}</td>
     <td width="55%" style="text-align: right; "> สำนักงานตำรวจตรวจคนเข้าเมือง จังหวัด เชียงราย</td>
     </tr></table>
     ');
     $pdf->SetFooter('
     <table width="100%" style="vertical-align: bottom; font-family: garuda; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;"><tr>
     <td width="33%"></td>
     <td width="33%"></td>
     <td width="55%" style="text-align: right; ">พิมพ์เมื่อ {DATE D} ที่ {DATE j-m-Y} เวลา {DATE H:i:s}  </td>
     </tr></table>
     ');
     $pdf->SetWatermarkText("");
     $pdf->SetDisplayMode('fullpage');
     $html = view('PDF.statistic')->with('data', $data)->render();
     //        return $html;
     $pdf->WriteHTML($html);
     return $data;
 }
 public function deleteCasePerson($caseId)
 {
     $data_person = Input::all();
     $case = DataCase::find($caseId);
     if ($data_person) {
         foreach ($data_person as $person) {
             if ($person) {
                 $case->criminalhistory()->detach($person->id);
                 if ($caseId) {
                     DataCase::find($caseId)->delete();
                     return $case;
                 }
             } else {
                 return null;
             }
         }
     } else {
         if ($caseId) {
             DataCase::find($caseId)->delete();
             return $case;
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $criminalhistory = CriminalHistory::find($id);
     Event::fire(new DeleteDataPersonCrimeEvent($criminalhistory));
     $dataspouse = $criminalhistory->dataspouse;
     $datamother = $criminalhistory->datamother;
     $datafather = $criminalhistory->datafather;
     $datapresentaddress = $criminalhistory->addresspresent;
     $dataoriginaladdress = $criminalhistory->addressoriginal;
     foreach ($criminalhistory->datacase as $datacase) {
         $caseId = $datacase->id;
         DataCase::find($caseId)->delete();
     }
     foreach ($criminalhistory->addressoffice as $addressoffice) {
         $addressofficeId = $addressoffice->id;
         AddressOffice::find($addressofficeId)->delete();
     }
     foreach ($criminalhistory->datachild as $datachild) {
         $datachildId = $datachild->id;
         DataChild::find($datachildId)->delete();
     }
     if ($criminalhistory) {
         CriminalHistory::find($id)->delete();
     }
     if ($dataspouse) {
         $spouseId = $dataspouse->id;
         DataSpouse::find($spouseId)->delete();
     }
     if ($datamother) {
         $motherId = $datamother->id;
         DataMother::find($motherId)->delete();
     }
     if ($datafather) {
         $fatherId = $datafather->id;
         DataFather::find($fatherId)->delete();
     }
     if ($datapresentaddress) {
         $presentId = $datapresentaddress->id;
         AddressPresent::find($presentId)->delete();
     }
     if ($dataoriginaladdress) {
         $original = $dataoriginaladdress->id;
         AddressOriginal::find($original)->delete();
     }
     return $criminalhistory;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($caseId, $vehicleId)
 {
     $datacase = DataCase::find($caseId);
     if ($vehicleId) {
         $vehicle = Vehicle::find($vehicleId)->delete();
         return $datacase;
     } else {
         return null;
     }
 }