/** * 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; }