/**
  * update Contact
  *
  * @param  Business            $business Business holding the Contact
  * @param  Contact             $contact  Contact to update
  * @param  AlterContactRequest $request  Alter Contact Request
  * @return Response                      Redirect back to edited Contact
  */
 public function update(Business $business, Contact $contact, AlterContactRequest $request)
 {
     $this->log->info(__METHOD__);
     $this->log->info(sprintf("  businessId:%s contactId:%s", $business->id, $contact->id));
     //////////////////
     // FOR REFACTOR //
     //////////////////
     $update = ['mobile' => $request->get('mobile'), 'mobile_country' => $request->get('mobile_country')];
     /* Only allow filling empty fields, not modification */
     if ($contact->birthdate === null && $request->get('birthdate')) {
         $update['birthdate'] = $request->get('birthdate');
         $this->log->info("BusinessContactController: update: Updated birthdate:{$update['birthdate']}");
     }
     if (trim($contact->nin) == '' && $request->get('nin')) {
         $update['nin'] = $request->get('nin');
         $this->log->info("BusinessContactController: update: Updated nin:{$update['nin']}");
     }
     $contact->update($update);
     $this->log->info("BusinessContactController: update: Updated contact");
     Flash::success(trans('user.contacts.msg.update.success'));
     return redirect()->route('user.business.contact.show', [$business, $contact]);
 }
Exemplo n.º 2
0
 /**
  * update Contact.
  *
  * @param Business            $business Business holding the Contact
  * @param Contact             $contact  Contact to update
  * @param AlterContactRequest $request  Alter Contact Request
  *
  * @return Response Redirect back to edited Contact
  */
 public function update(Business $business, Contact $contact, AlterContactRequest $request)
 {
     logger()->info(__METHOD__);
     logger()->info(sprintf('businessId:%s contactId:%s', $business->id, $contact->id));
     $this->authorize('manage', $contact);
     // BEGIN
     $data = ['firstname' => $request->get('firstname'), 'lastname' => $request->get('lastname'), 'email' => $request->get('email'), 'nin' => $request->get('nin'), 'gender' => $request->get('gender'), 'birthdate' => $request->get('birthdate'), 'mobile' => $request->get('mobile'), 'mobile_country' => $request->get('mobile_country')];
     $contact = $this->contactService->update($business, $contact, $data, $request->get('notes'));
     flash()->success(trans('user.contacts.msg.update.success'));
     return redirect()->route('user.business.contact.show', [$business, $contact]);
 }