Ejemplo n.º 1
0
 /**
  * Test all published universities and its details.
  */
 public function testPublishedUniversitiesWithDetails()
 {
     // get all published universities
     $response = $this->call('GET', $this->apiPrefix . '/universities?published=true');
     $hiddenFields = Rule::getDefaultHidden();
     Rule::setStaticHidden($hiddenFields);
     $universities = $this->parseJson($response);
     foreach ($universities as $university) {
         // get detailed university
         $detailedResponse = $this->call('GET', $this->apiPrefix . '/universities/' . $university->university_id . '?detailed=true');
         $detailedUniversity = $this->parseJson($detailedResponse);
         $this->checkSingleUniversityDetailed($detailedUniversity);
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $updatedAtServerPublished = Request::header('Updated-At-Server-Published');
     $updatedAtServerUnpublished = Request::header('Updated-At-Server-Unpublished');
     if (Input::has('published') && Input::get('published') === "true") {
         $universities = University::published(true)->newerThan($updatedAtServerPublished)->with("rules")->get();
         // hide fields which are not needed here
         $hiddenFields = Rule::getDefaultHidden();
         array_push($hiddenFields, "semester_format", "semester_pattern", "semester_start_summer", "semester_start_winter", "grade_factor", "overview");
         Rule::setStaticHidden($hiddenFields);
         return $universities;
     } else {
         // get all universities, but differentiate between published and unpublished
         $published = University::published(true)->newerThan($updatedAtServerPublished)->get();
         $unpublished = University::published(false)->newerThan($updatedAtServerUnpublished)->get();
         return $published->merge($unpublished)->all();
     }
 }