Esempio n. 1
0
 public function getUserById($userId)
 {
     $result = User::whereId($userId)->first();
     //first() function in sql returns the first value of the selected column
     return $result;
 }
 public function checkToken(Request $data, $token)
 {
     $objModelUser = User::getInstance();
     $whereForSearchToken = array('rawQuery' => 'pd_reset_token = ?', 'bindParams' => [$token]);
     $userDetails = $objModelUser->getUserWhere($whereForSearchToken);
     if ($userDetails) {
         if ($data->isMethod('post')) {
             $newPassword = $data->input('newpassword');
             $newPassword_confirmation = $data->input('newpassword_confirmation');
             $this->validate($data, ['newpassword' => 'required|min:3|confirmed', 'newpassword_confirmation' => 'required|min:3'], ['newpassword.required' => 'New Password Required']);
             $whereForUpdateUser = array('rawQuery' => 'pd_reset_token = ?', 'bindParams' => [$token]);
             $dataForUpdateUser = array('password' => Hash::make($newPassword), 'pd_reset_token' => '');
             $updated = $objModelUser->updateUserWhere($dataForUpdateUser, $whereForUpdateUser);
             return redirect('admin/login')->with(['message' => 'your password has successfully updated. please login now with the new password']);
         }
         return view('Admin::admin.resetpassword');
     } else {
         echo 'This link has expired';
     }
 }
 public function rejectedUsersAjaxHandler(Request $request)
 {
     $objModelUser = User::getInstance();
     $whereForUsers = array('rawQuery' => 'role = 1 and status = 3');
     $allRejectedUsers = $objModelUser->getAllUsersWhere($whereForUsers);
     //        return view('Admin::users.rejectedusers', ['rejected_users' => $allRejectedusers]);
     //       $var= print_r(json_decode(json_encode($allRejectedUsers), true));
     //        DB::statement(DB::raw('set @rownum=0'));
     //        $users = DB::table('users')
     //            ->select([ DB::raw('@rownum  := @rownum  + 1 AS rownum'), 'name', 'lastname', 'username', 'email'])
     //            ->where('role', '=', '1')
     //            ->where('status', '=', '3')
     //        ;
     //        dd($allRejectedUsers);
     $users = new Collection();
     $allRejectedUsers = json_decode(json_encode($allRejectedUsers), true);
     //        dd($allRejectedUsers);
     $i = 0;
     foreach ($allRejectedUsers as $valueRS) {
         $users->push(['id' => ++$i, 'fullname' => $valueRS['name'] . $valueRS['lastname'], 'username' => $valueRS['username'], 'email' => $valueRS['email']]);
     }
     return Datatables::of($users)->make(true);
 }