/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $name_father = Input::get('father_name');
     $surname_father = Input::get('father_surname');
     $name_mother = Input::get('mother_name');
     $surname_mother = Input::get('mother_surname');
     $name_spouse = Input::get('spouse_name');
     $surname_spouse = Input::get('spouse_surname');
     $present_address = Input::get('present_address');
     $original_address = Input::get('original_address');
     if ($present_address != null) {
         $addresspresent = new AddressPresent();
         $addresspresent->fill(Input::except(["data_casefile", "addressoffice", "datachild"]));
         $addresspresent->save();
     }
     if ($original_address != null) {
         $addressoriginal = new AddressOriginal();
         $addressoriginal->fill(Input::except(["data_casefile", "addressoffice", "datachild"]));
         $addressoriginal->save();
     }
     if ($name_mother != null || $surname_mother != null) {
         $datamother = new DataMother();
         $datamother->fill(Input::except(["data_casefile", "addressoffice", "datachild"]));
         $datamother->save();
     }
     if ($name_father != null || $surname_father != null) {
         $datafather = new DataFather();
         $datafather->fill(Input::except(["data_casefile", "addressoffice", "datachild"]));
         $datafather->save();
     }
     if ($name_spouse != null || $surname_spouse != null) {
         $dataspouse = new DataSpouse();
         $dataspouse->fill(Input::except(["data_casefile", "addressoffice", "datachild"]));
         $dataspouse->save();
     }
     $criminalhistory = new CriminalHistory();
     $criminalhistory->fill(Input::except(["data_casefile", "addressoffice", "datachild"]));
     if ($datamother != null) {
         $criminalhistory->datamother()->associate($datamother);
     }
     if ($datafather != null) {
         $criminalhistory->datafather()->associate($datafather);
     }
     if ($dataspouse != null) {
         $criminalhistory->dataspouse()->associate($dataspouse);
     }
     if ($addressoriginal != null) {
         $criminalhistory->addressoriginal()->associate($addressoriginal);
     }
     if ($addresspresent != null) {
         $criminalhistory->addresspresent()->associate($addresspresent);
     }
     $criminalhistory->save();
     $addressoffice = Input::get('addressoffice');
     $datachild = Input::get('datachild');
     foreach ($addressoffice as $data_office) {
         $office = new AddressOffice();
         $office->fill($data_office);
         $office->criminalhistory()->associate($criminalhistory);
         $office->save();
     }
     foreach ($datachild as $data_child) {
         $child = new DataChild();
         $child->fill($data_child);
         $child->criminalhistory()->associate($criminalhistory);
         $child->save();
     }
     return $criminalhistory;
 }
 /**
  * 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;
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $guesthistory = GuestHistory::find($id);
     Event::fire(new DeleteDataPersonGeneralEvent($guesthistory));
     $dataspouse = $guesthistory->dataspouse;
     $datamother = $guesthistory->datamother;
     $datafather = $guesthistory->datafather;
     $datapresentaddress = $guesthistory->addresspresent;
     $dataoriginaladdress = $guesthistory->addressoriginal;
     foreach ($guesthistory->vehicle as $vehicle) {
         $vehicleId = $vehicle->id;
         Vehicle::find($vehicleId)->delete();
     }
     foreach ($guesthistory->datachild as $datachild) {
         $datachildId = $datachild->id;
         DataChild::find($datachildId)->delete();
     }
     foreach ($guesthistory->employee as $employee) {
         $employeeId = $employee->id;
         Employee::find($employeeId)->delete();
     }
     foreach ($guesthistory->personfamily as $personfamily) {
         $personfamilyId = $personfamily->id;
         PersonFamily::find($personfamilyId)->delete();
     }
     if ($guesthistory) {
         GuestHistory::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 $guesthistory;
 }
 /**
  * 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;
 }