/**
  * Download searchresult in csv
  * @param Request $request
  */
 public function downloadSearchResultAsCSV(Request $request)
 {
     $currentPage = $request->get('page', 1);
     $filter = $this->processQueries($request);
     $filter['from'] = $currentPage;
     $contracts = $this->api->filterSearch($filter);
     echo $contracts;
 }
 /**
  * Home Page
  *
  * @param ImageService $image
  * @return \Illuminate\View\View
  */
 public function home(ImageService $image)
 {
     $image = $image->getHomePageImageUrl();
     $summary = $this->api->summary();
     $countries = count($summary->country_summary);
     $resources = count($summary->resource_summary);
     $contracts = $summary->contract_count;
     $countryName = get_country('name');
     return view('site.home', compact('countries', 'resources', 'contracts', 'image', 'countryName'));
 }
 /**
  * Page for a specific country
  *
  * @param         $country
  * @param Request $request
  * @return \Illuminate\View\View
  */
 public function detail(Request $request, $country)
 {
     $currentPage = $request->get('page', 1);
     $filter = ['country' => urldecode($country), 'from' => $currentPage, 'sort_by' => $request->get('sortby'), 'order' => $request->get('order')];
     $contracts = $this->api->allContracts($filter);
     $resources = $this->api->getResourceByCountry($filter);
     if (!$contracts) {
         return abort(404);
     }
     return view('country.detail', compact('contracts', 'country', 'resources', 'currentPage'));
 }
 public function annotations($contractId)
 {
     $contractAnnotationsObj = $this->api->getAnnotations($contractId);
     $annotation = [];
     if ($contractAnnotationsObj->total > 0) {
         foreach ($contractAnnotationsObj->result as $annotations) {
             $annotation[] = ['page' => $annotations->page_no, 'quote' => $annotations->quote, 'text' => $annotations->text, 'tags' => $annotations->tags];
         }
     }
     return $annotation;
 }
 /**
  * Download metadata in csv
  * @param Request $request
  */
 public function downloadMetadataAsCSV(Request $request)
 {
     $filter = ['country' => $request['country'], 'resource' => $request['resource'], 'download' => $request['download'], 'from' => 1];
     $this->api->allContracts($filter);
     die;
 }
 /**
  * Get All Page Text
  * @param         $contractId
  * @return json
  */
 public function getAllText($contractId)
 {
     $page = $this->api->getTextPage($contractId, "");
     return response()->json($page);
 }