public function findByUserNameOrCreate($userData) { $user = User::where('provider_id', '=', $userData->id)->orWhere('email', $userData->email)->first(); if (!$user) { $user = new User(); $user->provider_id = $userData->id; $user->name = $userData->name; $user->email = $userData->email; $user->avatar = $userData->avatar; $user->save(); } $this->checkIfUserNeedsUpdating($userData, $user); return $user; }
public function postRegister(Request $request) { $rules = ['name' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required|min:5', 'signup_confirm' => 'required']; $request->old('name'); $request->old('email'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { $message = $validator->messages(); return Redirect::route('register')->withInput()->withErrors($message); } $user = new User(); $user->name = $request->get('name'); $user->email = $request->get('email'); $user->password = Hash::make($request->get('password')); $user->save(); $currentUser = User::orderBy('id', 'Desc')->first(); $userId = new UserProfile(); $userId->user_id = $currentUser['id']; $userId->save(); Session::flash('register-successful', 'User has been successfully registered'); return Redirect::route('register'); }
public function postReset(Request $request) { // dd($request->get('password')); $rules = array('password' => 'required', 'confirmpassword' => 'required|same:password'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { $message = $validator->messages(); return Redirect::route('forgotPassword')->withErrors($message); } else { $user = User::where('remember_token', $request->get('_token'))->first(); $user->password = Hash::make($request->get('password')); $user->save(); Session::flash('password-change', 'Your Password is Changed..!!'); return view('login.login'); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $products = Product::all(); $userProducts = User_Product::all(); foreach ($userProducts as $up) { $userPrice = UserPrice::where('product_id', $up->products_id)->first(); $user = User::where('id', '=', $userPrice->user_id)->first(); $product = Product::where('id', '=', $up->products_id)->first(); $targetPrice = $userPrice->target_price; $checkUrl = new CheckUrl(); $provider = $checkUrl->checkurl($product->url); $priceFinder = new PriceFinder(); $productInfo = $priceFinder->{$provider}($product->url); if ($productInfo['price'] <= $targetPrice) { $data = array('price' => 'The price is now lower check it please' . ' ' . 'The link of this product is' . ' ' . $product->url); if ($user) { $subject = 'Track Your Price'; Mail::send('mail.price-notification', $data, function ($message) use($subject, $user) { $message->to($user->email, $user->name)->subject($subject); }); } } } }
public function deactivateAccount() { $userProduct = User_Product::select('products_id')->join('products', 'products.id', '=', 'user_product.products_id')->where('user_product.user_id', Auth::user()->id)->get()->count(); if ($userProduct > 0) { $message = 'If You Want to deactivate Your Account Please Delete All Products First...!!'; return Redirect::route('user-profile')->withErrors($message); } else { $user = User::where('id', Auth::user()->id)->delete(); $userProfile = UserProfile::where('user_id', Auth::user()->id)->delete(); return Redirect::route('register'); } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }