/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { //return Input::all(); $id_father = Input::get('datafather.id'); $id_mother = Input::get('datamother.id'); $id_spouse = Input::get('dataspouse.id'); $id_present_address = Input::get('addresspresent.id'); $id_original_address = Input::get('addressoriginal.id'); $father = Input::get('datafather'); $mother = Input::get('datamother'); $spouse = Input::get('dataspouse'); $presentaddress = Input::get('addresspresent'); $originaladdress = Input::get('addressoriginal'); $name_father = Input::get('datafather.father_name'); $surname_father = Input::get('datafather.father_surname'); $name_mother = Input::get('datamother.mother_name'); $surname_mother = Input::get('datamother.mother_surname'); $name_spouse = Input::get('dataspouse.spouse_name'); $surname_spouse = Input::get('dataspouse.spouse_surname'); $present_address = Input::get('addresspresent.present_address'); $original_address = Input::get('addressoriginal.original_address'); if (!$id_present_address) { if ($present_address != null) { $addresspresent = new AddressPresent(); $addresspresent->fill($presentaddress); $addresspresent->save(); } } else { $addresspresent1 = AddressPresent::find($id_present_address); $addresspresent1->fill($presentaddress); $addresspresent1->save(); } if (!$id_original_address) { if ($original_address != null) { $addressoriginal = new AddressOriginal(); $addressoriginal->fill($originaladdress); $addressoriginal->save(); } } else { $addressoriginal1 = AddressOriginal::find($id_original_address); $addressoriginal1->fill($originaladdress); $addressoriginal1->save(); } if (!$id_mother) { if ($name_mother != null || $surname_mother != null) { $datamother = new DataMother(); $datamother->fill($mother); $datamother->save(); } } else { $datamother1 = DataMother::find($id_mother); $datamother1->fill($mother); $datamother1->save(); } if (!$id_father) { if ($name_father != null || $surname_father != null) { $datafather = new DataFather(); $datafather->fill($father); $datafather->save(); } } else { $datafather1 = DataFather::find($id_father); $datafather1->fill($father); $datafather1->save(); } if (!$id_spouse) { if ($name_spouse != null || $surname_spouse != null) { $dataspouse = new DataSpouse(); $dataspouse->fill($spouse); $dataspouse->save(); } } else { $dataspouse1 = DataSpouse::find($id_spouse); $dataspouse1->fill($spouse); $dataspouse1->save(); } $guesthistory = GuestHistory::find($id); $guesthistory->fill(Input::except(["addoffice", "child", "employee", "family", "vehicle"])); if ($datamother != null) { $guesthistory->datamother()->associate($datamother); } if ($datafather != null) { $guesthistory->datafather()->associate($datafather); } if ($dataspouse != null) { $guesthistory->dataspouse()->associate($dataspouse); } if ($addressoriginal != null) { $guesthistory->addressoriginal()->associate($addressoriginal); } if ($addresspresent != null) { $guesthistory->addresspresent()->associate($addresspresent); } $guesthistory->save(); Event::fire(new EditDataPersonGeneralEvent($guesthistory)); return $guesthistory; }
/** * 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; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $id_father = Input::get('datafather.id'); $id_mother = Input::get('datamother.id'); $id_spouse = Input::get('dataspouse.id'); $id_present_address = Input::get('addresspresent.id'); $id_original_address = Input::get('addressoriginal.id'); $father = Input::get('datafather'); $mother = Input::get('datamother'); $spouse = Input::get('dataspouse'); $presentaddress = Input::get('addresspresent'); $originaladdress = Input::get('addressoriginal'); $name_father = Input::get('datafather.father_name'); $surname_father = Input::get('datafather.father_surname'); $name_mother = Input::get('datamother.mother_name'); $surname_mother = Input::get('datamother.mother_surname'); $name_spouse = Input::get('dataspouse.spouse_name'); $surname_spouse = Input::get('dataspouse.spouse_surname'); $present_address = Input::get('addresspresent.present_address'); $original_address = Input::get('addressoriginal.original_address'); if (!$id_present_address) { if ($present_address != null) { $addresspresent = new AddressPresent(); $addresspresent->fill($presentaddress); $addresspresent->save(); } } else { $addresspresent1 = AddressPresent::find($id_present_address); $addresspresent1->fill($presentaddress); $addresspresent1->save(); } if (!$id_original_address) { if ($original_address != null) { $addressoriginal = new AddressOriginal(); $addressoriginal->fill($originaladdress); $addressoriginal->save(); } } else { $addressoriginal1 = AddressOriginal::find($id_original_address); $addressoriginal1->fill($originaladdress); $addressoriginal1->save(); } if (!$id_mother) { if ($name_mother != null || $surname_mother != null) { $datamother = new DataMother(); $datamother->fill($mother); $datamother->save(); } } else { $datamother1 = DataMother::find($id_mother); $datamother1->fill($mother); $datamother1->save(); } if (!$id_father) { if ($name_father != null || $surname_father != null) { $datafather = new DataFather(); $datafather->fill($father); $datafather->save(); } } else { $datafather1 = DataFather::find($id_father); $datafather1->fill($father); $datafather1->save(); } if (!$id_spouse) { if ($name_spouse != null || $surname_spouse != null) { $dataspouse = new DataSpouse(); $dataspouse->fill($spouse); if (Input::has('dataspouse.nametitle.id')) { $nametitle = NameTitle::find(Input::get('dataspouse.nametitle.id')); $dataspouse->nametitle()->associate($nametitle); } $dataspouse->save(); } } else { $dataspouse1 = DataSpouse::find($id_spouse); $dataspouse1->fill($spouse); if (Input::has('dataspouse.nametitle.id')) { $nametitle = NameTitle::find(Input::get('dataspouse.nametitle.id')); $dataspouse1->nametitle()->associate($nametitle); } $dataspouse1->save(); } $criminalhistory = CriminalHistory::find($id); $criminalhistory->fill(Input::except(["datacase", "addressoffice", "addressoriginal", "addresspresent", "datachild", "datafather", "datamother", "dataspouse"])); if (Input::has('nametitle.id')) { $nametitle = NameTitle::find(Input::get('nametitle.id')); $criminalhistory->nametitle()->associate($nametitle); } 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(); Event::fire(new EditDataPersonCrimeEvent($criminalhistory)); return $criminalhistory; }