Skip to content

Commit

Permalink
Merge pull request #19 from ryanaidilp/4.0.7
Browse files Browse the repository at this point in the history
update to version 4.0.7
  • Loading branch information
ryanaidilp authored Apr 9, 2021
2 parents 85144cf + 0282295 commit e2e4455
Show file tree
Hide file tree
Showing 16 changed files with 479 additions and 234 deletions.
9 changes: 9 additions & 0 deletions app/Helpers/AppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ function sendNotification($body, $header)
'Authorization' => 'Basic ' . env('ONESIGNAL_API_KEY')
])->retry(3, 1000)->post(env('ONESIGNAL_API_URL'), $fields);
}

function setResponse($data, $errors, $isSuccess)
{
return [
'success' => $isSuccess,
'errors' => $errors,
'data' => $data
];
}
91 changes: 91 additions & 0 deletions app/Http/Controllers/Api/StatisticController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Statistic;
use App\Transformers\AppSerializer;
use App\Transformers\StatisticTransformer;
use Illuminate\Http\Request;

class StatisticController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$statistics = Statistic::with(['histories'])->get();
$statistics = \fractal($statistics, new StatisticTransformer, new AppSerializer)->toArray();
$statistics = \setResponse($statistics, [], true);
return \response($statistics, 200);
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param \App\Models\Statistic $statistic
* @return \Illuminate\Http\Response
*/
public function show(Statistic $statistic)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Statistic $statistic
* @return \Illuminate\Http\Response
*/
public function edit(Statistic $statistic)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Statistic $statistic
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Statistic $statistic)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param \App\Models\Statistic $statistic
* @return \Illuminate\Http\Response
*/
public function destroy(Statistic $statistic)
{
//
}
}
4 changes: 0 additions & 4 deletions app/Http/Controllers/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public function data()
$districts = District::all();
$provinces = Province::all();
$tests = fractal(Test::all(), new TestTransformer)->toArray();
$data = fractal(Statistic::with('histories')->get(), new StatisticTransformer)->toArray();
$nationals = fractal(NationalCaseHistory::all(), new NationalStatisticTransformer)->toArray();
$genders = fractal(Gender::latest()->first(), new GenderTransformer)->toArray();
return Inertia::render("Data/Index", [
Expand All @@ -113,9 +112,6 @@ public function data()
'map_id' => $province->map_id
];
})->toArray(),
'recapLocal' => function () use ($data) {
return $data['data'];
},
'recapNational' => function () use ($nationals) {
return $nationals['data'];
},
Expand Down
Loading

0 comments on commit e2e4455

Please sign in to comment.