update api kurs and function
This commit is contained in:
parent
17f5e2c111
commit
c95c5b5720
@ -16,22 +16,35 @@ class FrontendController extends Controller
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
if (File::exists('storage/kurs.json')) {
|
||||||
$json = File::get('storage/kurs.json');
|
$json = File::get('storage/kurs.json');
|
||||||
$kurs = json_decode($json);
|
$kurs = json_decode($json);
|
||||||
if($kurs->date != date('Y-m-d')){
|
$date = Carbon::createFromTimestamp($kurs->time_last_update_unix)->format('Y-m-d');
|
||||||
|
if ($date != date('Y-m-d')) {
|
||||||
|
$this->getKurs();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$this->getKurs();
|
$this->getKurs();
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = File::get('storage/kurs.json');
|
$json = File::get('storage/kurs.json');
|
||||||
$kurs = json_decode($json);
|
$kurs = json_decode($json);
|
||||||
$usd = $kurs->rates->IDR/$kurs->rates->USD;
|
$usd = $kurs->conversion_rate;
|
||||||
$date = Carbon::createFromTimestamp($kurs->timestamp)->locale('id')->setTimezone('Asia/Jakarta')->translatedFormat('d F Y H:i:s');
|
|
||||||
|
|
||||||
$sheets = Sheets::spreadsheet('1c2Uv3QVTyLzsJPE4uqqlMGNKO8z0Kqj6aEGh0uixAqA')->sheet('Platform')->range('A:F')->get();
|
$date = Carbon::createFromTimestamp($kurs->time_last_update_unix)
|
||||||
|
->locale('id')
|
||||||
|
->setTimezone('Asia/Jakarta')
|
||||||
|
->translatedFormat('d F Y H:i:s');
|
||||||
|
|
||||||
|
$sheets = Sheets::spreadsheet('1c2Uv3QVTyLzsJPE4uqqlMGNKO8z0Kqj6aEGh0uixAqA')
|
||||||
|
->sheet('Platform')
|
||||||
|
->range('A:F')
|
||||||
|
->get();
|
||||||
$header = $sheets->pull(0);
|
$header = $sheets->pull(0);
|
||||||
$posts = Sheets::collection($header, $sheets);
|
$posts = Sheets::collection($header, $sheets);
|
||||||
$posts = $posts->take(5000);
|
$posts = $posts->take(5000);
|
||||||
@ -44,18 +57,29 @@ class FrontendController extends Controller
|
|||||||
public function cakupan()
|
public function cakupan()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (File::exists('storage/kurs.json')) {
|
||||||
$json = File::get('storage/kurs.json');
|
$json = File::get('storage/kurs.json');
|
||||||
$kurs = json_decode($json);
|
$kurs = json_decode($json);
|
||||||
if($kurs->date != date('Y-m-d')){
|
$date = Carbon::createFromTimestamp($kurs->time_last_update_unix)->format('Y-m-d');
|
||||||
|
if ($date != date('Y-m-d')) {
|
||||||
|
$this->getKurs();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$this->getKurs();
|
$this->getKurs();
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = File::get('storage/kurs.json');
|
$json = File::get('storage/kurs.json');
|
||||||
$kurs = json_decode($json);
|
$kurs = json_decode($json);
|
||||||
$usd = $kurs->rates->IDR/$kurs->rates->USD;
|
$usd = $kurs->conversion_rate;
|
||||||
$date = Carbon::createFromTimestamp($kurs->timestamp)->locale('id')->setTimezone('Asia/Jakarta')->translatedFormat('d F Y H:i:s');
|
$date = Carbon::createFromTimestamp($kurs->time_last_update_unix)
|
||||||
|
->locale('id')
|
||||||
|
->setTimezone('Asia/Jakarta')
|
||||||
|
->translatedFormat('d F Y H:i:s');
|
||||||
|
|
||||||
$sheets = Sheets::spreadsheet('1c2Uv3QVTyLzsJPE4uqqlMGNKO8z0Kqj6aEGh0uixAqA')->sheet('Platform')->range('A:F')->get();
|
$sheets = Sheets::spreadsheet('1c2Uv3QVTyLzsJPE4uqqlMGNKO8z0Kqj6aEGh0uixAqA')
|
||||||
|
->sheet('Platform')
|
||||||
|
->range('A:F')
|
||||||
|
->get();
|
||||||
$header = $sheets->pull(0);
|
$header = $sheets->pull(0);
|
||||||
$posts = Sheets::collection($header, $sheets);
|
$posts = Sheets::collection($header, $sheets);
|
||||||
$data = new Collection($posts->toArray());
|
$data = new Collection($posts->toArray());
|
||||||
@ -65,7 +89,10 @@ class FrontendController extends Controller
|
|||||||
|
|
||||||
public function peneliti()
|
public function peneliti()
|
||||||
{
|
{
|
||||||
$sheets = Sheets::spreadsheet('1kM32QnxjRDpH1WkFSfOwMuTKzoCQpXFDYhekARcypjY')->sheet('Research Proposal')->range('A:K')->get();
|
$sheets = Sheets::spreadsheet('1kM32QnxjRDpH1WkFSfOwMuTKzoCQpXFDYhekARcypjY')
|
||||||
|
->sheet('Research Proposal')
|
||||||
|
->range('A:K')
|
||||||
|
->get();
|
||||||
$header = $sheets->pull(0);
|
$header = $sheets->pull(0);
|
||||||
$posts = Sheets::collection($header, $sheets);
|
$posts = Sheets::collection($header, $sheets);
|
||||||
$posts = $posts->take(5000);
|
$posts = $posts->take(5000);
|
||||||
@ -98,7 +125,9 @@ class FrontendController extends Controller
|
|||||||
|
|
||||||
public function facility()
|
public function facility()
|
||||||
{
|
{
|
||||||
$sheets = Sheets::spreadsheet('1kM32QnxjRDpH1WkFSfOwMuTKzoCQpXFDYhekARcypjY')->sheet('Sequencing Facility')->get();
|
$sheets = Sheets::spreadsheet('1kM32QnxjRDpH1WkFSfOwMuTKzoCQpXFDYhekARcypjY')
|
||||||
|
->sheet('Sequencing Facility')
|
||||||
|
->get();
|
||||||
$header = $sheets->pull(0);
|
$header = $sheets->pull(0);
|
||||||
$posts = Sheets::collection($header, $sheets);
|
$posts = Sheets::collection($header, $sheets);
|
||||||
$posts = $posts->take(5000);
|
$posts = $posts->take(5000);
|
||||||
@ -145,13 +174,15 @@ class FrontendController extends Controller
|
|||||||
{
|
{
|
||||||
return view('frontend::ci');
|
return view('frontend::ci');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function silx_ic()
|
public function silx_ic()
|
||||||
{
|
{
|
||||||
return view('frontend::ic');
|
return view('frontend::ic');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKurs(){
|
public function getKurs()
|
||||||
$response = Http::get('http://api.exchangeratesapi.io/v1/latest?access_key=9f7cd7db5b72280a93c8e15243fadab7&symbols=USD,IDR');
|
{
|
||||||
|
$response = Http::get('https://v6.exchangerate-api.com/v6/7ac9163481b1e658bc0ef6a5/pair/USD/IDR');
|
||||||
$data = $response->json();
|
$data = $response->json();
|
||||||
Storage::disk('public')->put('kurs.json', json_encode($data));
|
Storage::disk('public')->put('kurs.json', json_encode($data));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user