/** * Display a listing of the resource. * * @return Response */ public function index() { $headers = apache_request_headers(); $response = array(); if (isset($headers['api_key'])) { $apiKey = UserNew::where('api_key', '=', $headers['api_key'])->first(); if (sizeof($apiKey) > 0) { $categories = $this->category->get(); $subCategories = array(); foreach ($categories as $category) { $subCategories['id'] = $category['id']; $subCategories['name'] = $category['name']; $subCats = DepartmentSubCategory::where('category', '=', $category['id'])->get(); $tmpArrayAll = []; foreach ($subCats as $subCat) { $tmpArray['cat_id'] = $category['id']; $tmpArray['id'] = $subCat['id']; $tmpArray['name'] = $subCat['name']; $subsubCats = DepartmentSubSubCategory::where('sub_category', '=', $subCat['id'])->get(); $tmpArrayAll2 = []; foreach ($subsubCats as $subsubCat) { $tmpA['cat_id'] = $subCat['id']; $tmpA['id'] = $subsubCat['id']; $tmpA['name'] = $subsubCat['name']; $tmpArrayAll2[] = $tmpA; } $tmpArray['subs'] = $tmpArrayAll2; $tmpArrayAll[] = $tmpArray; } $subCategories['subs'] = $tmpArrayAll; $tmp[] = $subCategories; } $response['categories'] = $tmp; $response['error'] = FALSE; return \Response::json($response, 201); } else { $response['message'] = 'Access Denied. Invalid Api key'; $response['error'] = TRUE; return \Response::json($response, 401); } } else { $response['message'] = 'Access Denied. Invalid Api key'; $response['error'] = TRUE; return \Response::json($response, 401); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function myReport(Report $report) { $headers = apache_request_headers(); $response = array(); if (isset($headers['api_key'])) { $user = UserNew::where('api_key', '=', $headers['api_key_new'])->first(); if (sizeof($user) > 0) { $myReports = \DB::table('cases')->leftjoin('departments', 'cases.department', '=', 'departments.id')->join('categories', 'cases.category', '=', 'categories.id')->join('sub-categories', 'cases.sub_category', '=', 'sub-categories.id')->leftjoin('sub-sub-categories', 'cases.sub_sub_category', '=', 'sub-sub-categories.id')->join('users', 'cases.user', '=', 'users.id')->where('cases.user', '=', $user->id)->select(\DB::raw("cases.id, cases.created_at,cases.status,cases.description,cases.priority,cases.img_url,cases.gps_lat,cases.gps_lng,categories.name as category,`sub-categories`.name as sub_category,`sub-sub-categories`.name as sub_sub_category"))->get(); $response["error"] = FALSE; $response["reports"] = $myReports; return \Response::json($response, 201); } else { $response['message'] = 'Access Denied. Invalid Api key'; $response['error'] = TRUE; return \Response::json($response, 401); } } else { $response['message'] = 'Access Denied. Invalid Api key'; $response['error'] = TRUE; return \Response::json($response, 401); } }
public static function getAll() { return UserNew::get(); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function forgot(User $user) { $response = array(); $cell = \Input::get('cell'); $password = \Input::get('password'); \Log::info('Password Change: User ' . $cell . "New Password" . $password); $userNew = UserNew::where('cellphone', '=', $cell)->first(); if (sizeof($userNew) > 0) { $userNew->password = \Hash::make($password); $userNew->save(); $response["error"] = false; $response["message"] = "You have successfully changed your password"; } else { $response["error"] = true; $response["message"] = "Sorry, you have not registered yet"; } return \Response::json($response); }