/**
  * Update the user's settings.
  *
  * @param \Tricks\User $user
  * @param array        $data
  *
  * @return \Tricks\User
  */
 public function updateSettings(User $user, array $data)
 {
     $user->username = $data['username'];
     if ($data['password'] != '') {
         $user->password = Hash::make($data['password']);
     }
     if ($data['avatar'] != '') {
         File::move(public_path() . '/img/avatar/temp/' . $data['avatar'], 'img/avatar/' . $data['avatar']);
         if ($user->photo) {
             File::delete(public_path() . '/img/avatar/' . $user->photo);
         }
         $user->photo = $data['avatar'];
     }
     return $user->save();
 }
Esempio n. 2
0
 /**
  * Update the user's settings.
  *
  * @param  \Tricks\User  $user
  * @param  array $data
  * @return \Tricks\User
  */
 public function updateSettings(User $user, array $data)
 {
     $user->username = $data['username'];
     $user->companyname = $data['companyname'];
     $user->phonenumber = $data['phonenumber'];
     $user->Address = $data['Address'];
     $user->flag_name = $data['flag_name'];
     /*if ($data['flag_name'] = ''){
              $user->flag_name = 0;#$data['flag_name'];
     
             }
             else
             {
                 $user->flag_name = 1;
             }
             */
     $user->password = $data['password'] != '' ? $data['password'] : $user->password;
     //Hash::make($data['password']) : $user->password;
     if ($data['avatar'] != '') {
         File::move(public_path() . '/img/avatar/temp/' . $data['avatar'], 'img/avatar/' . $data['avatar']);
         if ($user->photo) {
             File::delete(public_path() . '/img/avatar/' . $user->photo);
         }
         $user->photo = $data['avatar'];
     }
     return $user->save();
 }