public function adminlogin(Request $data)
 {
     //        dd($data); die;
     if (Session::has('fs_admin') || $data->session()->has('fs_admin')) {
         //|| Session::has('fs_manager')
         return redirect('/admin/dashboard');
     }
     if ($data->isMethod('post')) {
         $email = $data->input('email');
         $password = $data->input('password');
         /* BELOW BLOCK TO INSERT ADMIN USER FIRST TIME
                     $objUser = new User();
                     $data = array(
                         'name' => 'FlashSale Admin',
                         'username' => 'admin',
                         'email' => '*****@*****.**',
                         'password' => Hash::make('admin'),
         //                'added_date' => time(),
                         'role' => "5",
                         'status' => '1'
                     );
                     $result = DB::table('users')->insert($data);
         //            $result = $objUser->addNewUser($data);
                     echo "<pre>"; print_r($result);
                     die; */
         $this->validate($data, ['email' => 'required|email', 'password' => 'required'], ['email.required' => 'Please enter email address or username', 'password.required' => 'Please enter a password']);
         if (Auth::attempt(['email' => $email, 'password' => $password])) {
             $objModelUsers = User::getInstance();
             //                User::getInstance();
             $userDetails = $objModelUsers->getUserById(Auth::id());
             //THIS IS TO GET THE MODEL OBJECT
             //                $userDetails = DB::table('users')->select()->where('id', 1)->first(); //USED TO GET ROW OBJECT
             //                echo "<pre>"; print_r($userDetails); die;
             if ($userDetails->role == 5) {
                 $sessionName = 'fs_admin';
                 Session::put($sessionName, $userDetails['original']);
                 return redirect('/admin/dashboard');
             } else {
                 return redirect('/admin/login')->withErrors(['errMsg' => 'Invalid credentials.']);
             }
             //                if ($userDetails['role'] == 4) {
             //                    $sessionName = 'fs_manager';
             //                }
         } else {
             return redirect('/admin/login')->withErrors(['errMsg' => 'Invalid credentials.']);
         }
     }
     return view("Admin/Layouts/adminlogin");
 }
 public function editCustomer(Request $request, $uid)
 {
     $postdata = $request->all();
     $ObjUser = User::getInstance();
     if ($request->isMethod("GET")) {
         // $where = ['rawQuery' => 'id = ?', 'bindParams' => $uid];
         $customerDetails = $ObjUser->getUserById($uid);
         return view('Admin/Views/customer/editCustomer', ['userdetail' => $customerDetails]);
     } else {
         if ($request->isMethod("POST")) {
             $data['name'] = $postdata['firstname'];
             $data['last_name'] = $postdata['lastname'];
             $data['email'] = $postdata['email'];
             $data['username'] = $postdata['username'];
             $result = $ObjUser->updateUserInfo($data, $uid);
             if ($result) {
                 return Redirect::back()->with(['status' => 'success', 'msg' => 'Details Suuccesfully Edited.']);
             } else {
                 return Redirect::back()->with(['status' => 'success', 'msg' => 'Some Error Occured.']);
             }
         }
     }
 }
 public function editManager(Request $request, $mid)
 {
     $ObjPermissions = Permissions::getInstance();
     $ObjUser = User::getInstance();
     $postData = $request->all();
     $ObjPermissionUserRelation = PermissionUserRelation::getInstance();
     if ($request->isMethod('GET')) {
         $where = ['rawQuery' => 'permission_id  NOT IN (1)'];
         //To Do // Permission id not to be fetched from query //
         $permissionDetails = $ObjPermissions->getAllPermissions($where);
         $wherepermission = ['rawQuery' => 'id = ?', 'bindParams' => [$mid]];
         $permissionInfo = $ObjUser->getUserInfoById($wherepermission);
         //   $catfilterName = array_unique(explode(',', $permissionInfo->permission_ids));
         $wherepermit = ['rawQuery' => 'permission_id IN(' . $permissionInfo->permission_ids . ')'];
         $Info = $ObjPermissions->getPermitDetail($wherepermit);
         foreach ($Info as $key => $value) {
             $permissionIds[$key] = $value->permission_id;
         }
         return view('Admin/Views/manager/editManager', ['permissionlist' => $permissionDetails, 'permissionInfo' => $permissionInfo, 'info' => $permissionIds]);
     } elseif ($request->isMethod('POST')) {
         $rules = array('username' => 'unique:users,username.' . $mid . ',id');
         $data['name'] = $postData['firstname'];
         $data['last_name'] = $postData['lastname'];
         $data['username'] = $postData['username'];
         $data['email'] = $postData['email'];
         //            $where = ['rawQuery' => 'id = ?', 'bindParams' => [$mid]];
         //$where['id'] = $mid;
         $updateUser = $ObjUser->updateUserInfo($data, $mid);
         if ($updateUser) {
             $temp = array();
             $cat = $postData['permitcheck'];
             foreach ($cat as $catkey => $catval) {
                 $category[$catkey] = $catval;
             }
             //            $FilterGroup = $ObjProductCategory->getCategoryInfoById($category);
             $where = ['rawQuery' => 'user_id = ?', 'bindParams' => [$mid]];
             $FilterGroup = $ObjPermissionUserRelation->getPermissionDetailsById($where);
             $catdata = $FilterGroup[0]->permission_ids;
             $cata = explode(",", $catdata);
             $categoryIds = implode(',', $category);
             array_push($cata, $categoryIds);
             //$catmain = implode(",", $cata);
             $data1['permission_ids'] = $categoryIds;
             $updatePermission = $ObjPermissionUserRelation->updatePermissionInfo($data1, $where);
         }
         if ($updateUser && $updatePermission) {
             return Redirect::back()->with(['status' => 'success', 'msg' => 'Successfully Edited ']);
         } else {
             return Redirect::back()->with(['status' => 'success', 'msg' => 'Some Error']);
         }
     }
 }