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 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');
     }
 }
Beispiel #3
0
 /**
  * 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');
     }
 }