/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     if (Auth::user()->id == $id) {
         if ($user = User::where('id', '=', $id)->first()) {
             $contact = UserContact::firstOrCreate(array('user_id' => $id));
             // echo "<pre>";
             // print_r($user);
             // print_r($contact);exit;
             return View::make('account.profile')->with('user', $user)->with('contact', $contact);
         }
     } else {
         App::abort(403, 'Unauthorized action.');
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update3($id)
 {
     // Transaction begins here
     \DB::beginTransaction();
     //user data
     $displayname = \Input::get('displayname');
     //call user model
     $user = \User::find($id);
     $user->displayname = $displayname;
     //update
     if (!$user->save()) {
         \DB::callback();
         return \Redirect::back()->with('error', 'Failed to update');
     }
     //user contact detail
     $mobile = \Input::get('mobile');
     $alt_mobile = \Input::get('alt_mobile');
     $alt_email = \Input::get('alt_email');
     //call user contact model
     $contact = \UserContact::firstOrCreate(array('user_id' => $id));
     $contact->mobile = $mobile;
     $contact->alt_mobile = $alt_mobile;
     $contact->alt_email = $alt_email;
     // update table
     if (!$contact->save()) {
         \DB::callback();
         return \Redirect::back()->with('error', 'Failed to update');
     }
     //Company detail
     $company_name = \Input::get('company_name');
     $company_address = \Input::get('company_address');
     $company_city = \Input::get('company_city');
     $company_state = \Input::get('company_state');
     $company_pin = \Input::get('company_pin');
     $company_land_line = \Input::get('company_land_line');
     $company_alt_land_line = \Input::get('company_alt_land_line');
     $company_fax = \Input::get('company_fax');
     $company_website = \Input::get('company_website');
     //call company model
     $company = \Company::firstOrCreate(array('user_id' => $id));
     $company->company_name = $company_name;
     $company->company_address = $company_address;
     $company->company_city = $company_city;
     $company->company_state = $company_state;
     $company->company_pin = $company_pin;
     $company->company_phone = $company_land_line;
     $company->company_alt_phone = $company_alt_land_line;
     $company->company_fax = $company_fax;
     $company->company_website = $company_website;
     // update table
     if (!$company->save()) {
         \DB::rollback();
         return \Redirect::back()->with('error', 'Failed to update');
     } else {
         \DB::commit();
         return \Redirect::route('branch.client.index')->with('success', 'Successfully updated');
     }
 }