Skip to content

Commit

Permalink
change object to array
Browse files Browse the repository at this point in the history
  • Loading branch information
afiqiqmal committed Aug 18, 2018
1 parent b72ffe9 commit a9fdba5
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 68 deletions.
156 changes: 105 additions & 51 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions example/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@

$holiday = new Holiday;

echo $holiday->getRegionHoliday("Selangor")->filterByMonth('January')->get();
//echo $holiday->getAllRegionHoliday()->get();
$result = $holiday->getRegionHoliday(['Selangor', 'Malacca'])->get();

//print_r($result);
header('Content-Type: application/json');
echo json_encode($result['data']['Selangor']);
9 changes: 3 additions & 6 deletions src/Holiday.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,17 @@ public function get()

$this->result['data'] = $temp;

header('Content-Type: application/json');
return json_encode($this->result, JSON_PRETTY_PRINT);
return $this->result;
} elseif ($this->groupByMonth) {
foreach ($this->result['data'] as $key => $holiday) {
$temp[date('F', strtotime($holiday['date']))][] = $holiday;
}

$this->result['data'] = $temp;

header('Content-Type: application/json');
return json_encode($this->result, JSON_PRETTY_PRINT);
return $this->result;
} else {
header('Content-Type: application/json');
return json_encode($this->result, JSON_PRETTY_PRINT);
return $this->result;
}
} else {
return [
Expand Down
Loading

0 comments on commit a9fdba5

Please sign in to comment.