/** * Edit profile * *@return redirect */ function postEditProfile() { $id = Input::get('id'); $rules = array('company_name' => 'required|min:2', 'first_name' => 'required|min:2', 'last_name' => 'required|min:2', 'email' => 'required|email|unique:profiles,email,' . $id, 'password' => 'min:5', 'company_name' => 'required|min:2', 'address' => 'required|min:2', 'phone_number' => 'required|min:5', 'mobile' => 'required|min:5', 'country' => 'required', 'city' => 'required|min:2', 'passport_img' => 'mimes:jpg,png,gif', 'id_img' => 'mimes:jpg,png,gif', 'driving_img' => 'mimes:jpg,png,gif', 'bill_img' => 'mimes:jpg,png,gif'); $validator = Validator::make(Input::all(), $rules); if ($validator->passes()) { $company_name = Input::get('company_name'); $first_name = Input::get('first_name'); $last_name = Input::get('last_name'); $email = Input::get('email'); $password = Input::get('password'); $address = Input::get('address'); $phone1 = Input::get('phone_number'); $phone2 = Input::get('phone_number2'); $mobile = Input::get('mobile'); $website = Input::get('website'); $country = Input::get('country'); $city = Input::get('city'); $update = ['company_name' => $company_name, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'address' => $address, 'phone1' => $phone1, 'phone2' => $phone2, 'mobile' => $mobile, 'website' => $website, 'country' => $country, 'city' => $city]; if (Input::file('passport_img')) { $update['passport_img'] = 'passport_img.jpg'; } if (Input::file('id_img')) { $update['id_img'] = 'id_img.jpg'; } if (Input::file('driving_img')) { $update['driving_img'] = 'driving_img.jpg'; } if (Input::file('bill_img')) { $update['bill_img'] = 'bill_img.jpg'; } if ($password != '') { $update['password'] = sha1($password); } ProfileModel::updateProfile($id, $update); $update2 = ['email' => $email]; if ($password != '') { $update2['password'] = sha1($password); } ProfileModel::updateVendor($id, $update2); Upload::uploadPassport($id); Upload::uploadID($id); Upload::uploadDrivingLicense($id); Upload::uploadUtilityBil($id); return Redirect::to('/profile')->with('s_msg', 'Profile information updated!'); } return Redirect::to('/profile')->with('e_msg', 'Something went wrong!')->withErrors($validator)->withInput(); }