public function updateProfile() { $name = Input::get('name'); //$username = Input::get('username'); $birthday = Input::get('birthday'); $bio = Input::get('bio', ''); $gender = Input::get('gender'); $mobile_no = Input::get('mobile_no'); $country = Input::get('country'); $old_avatar = Input::get('old_avatar'); /*if(\Cashout\Models\User::where('username',$username)->where('id','!=',Auth::user()->id)->count()>0){ Session::flash('error_msg', 'Username is already taken by other user . Please enter a new username'); return Redirect::back()->withInput(Input::all(Input::except(['_token']))); }*/ try { $profile = \Cashout\Models\User::findOrFail(Auth::user()->id); $profile->name = $name; // $profile->username = $username; $profile->birthday = $birthday; $profile->bio = $bio; $profile->gender = $gender; $profile->mobile_no = $mobile_no; $profile->country = $country; $profile->avatar = Input::hasFile('avatar') ? \Cashout\Helpers\Utils::imageUpload(Input::file('avatar'), 'profile') : $old_avatar; $profile->save(); Session::flash('success_msg', 'Profile updated successfully'); return Redirect::back(); } catch (\Exception $e) { Session::flash('error_msg', 'Unable to update profile'); return Redirect::back()->withInput(Input::all(Input::except(['_token', 'avatar']))); } }
static function generateReferralCode() { $temp_code = Str::random(10); $count = DB::table('users')->where('referral_code', $temp_code)->count(); if ($count > 0) { //Code Exists Utils::generateReferralCode(); } else { return $temp_code; } }
public function storeAccount() { $userManager = new \KodeInfo\UserManagement\UserManagement(); try { $user = $userManager->createUser(Input::all(), Input::get('group', 'admin'), true); if (Input::hasFile('avatar')) { $user->avatar = \Cashout\Helpers\Utils::imageUpload(Input::file('avatar'), 'profile'); $user->save(); } Session::flash('success_msg', 'Admin created successfully'); return Redirect::back(); } catch (\KodeInfo\UserManagement\Exceptions\AuthException $e) { Session::flash('error_msg', \Cashout\Helpers\Utils::buildMessages($e->getErrors())); return Redirect::back(); } }
public function postLogin() { try { $this->userManager->login(["email" => Input::get('email'), "password" => Input::get('password')], Input::has('remember_me'), true); return Redirect::to('/dashboard'); } catch (\KodeInfo\UserManagement\Exceptions\AuthException $e) { Session::flash('error_msg', Utils::buildMessages($e->getErrors())); return Redirect::back(); } }
private function addUsers() { $password = Hash::make('311311'); $user = new User(); $user->name = "Imran Iqbal"; $user->email = "*****@*****.**"; $user->password = $password; $user->referral_code = Utils::generateReferralCode(); $user->activated = 1; $user->save(); $user_groups = new \Cashout\Models\UsersGroups(); $user_groups->group_id = 2; $user_groups->user_id = $user->id; $user_groups->save(); $user = new User(); $user->name = "Imran Iqbal"; $user->email = "*****@*****.**"; $user->password = $password; $user->referral_code = Utils::generateReferralCode(); $user->activated = 1; $user->save(); $user_groups = new \Cashout\Models\UsersGroups(); $user_groups->group_id = 2; $user_groups->user_id = $user->id; $user_groups->save(); $this->command->info("Created Admins Vincent and Imran ...."); for ($i = 1; $i < 20; $i++) { $user = new User(); $user->name = "User {$i}"; $user->email = "user{$i}@gmail.com"; $user->password = $password; $user->referral_code = Utils::generateReferralCode(); $user->activated = 1; $user->save(); $user_groups = new \Cashout\Models\UsersGroups(); $user_groups->group_id = 1; $user_groups->user_id = $user->id; $user_groups->save(); $this->command->info("User {$i} ...."); } $this->command->info('Seeding referrals ....'); $user_referral = new UserReferral(); $user_referral->referral_id = 1; $user_referral->user_id = 2; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 1; $user_referral->user_id = 3; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 2; $user_referral->user_id = 4; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 2; $user_referral->user_id = 5; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 3; $user_referral->user_id = 6; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 3; $user_referral->user_id = 7; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 4; $user_referral->user_id = 8; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 4; $user_referral->user_id = 9; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 5; $user_referral->user_id = 10; $user_referral->save(); $user_referral = new UserReferral(); $user_referral->referral_id = 5; $user_referral->user_id = 11; $user_referral->save(); $this->command->info('Done ....'); }