# Conflicts:
#	Http/Controllers/FrontendController.php
This commit is contained in:
Daeng Deni Mardaeni 2023-09-13 23:38:21 +07:00
commit 540869408d

View File

@ -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);
@ -41,49 +54,32 @@ class FrontendController extends Controller
return view('frontend::index', compact('kurs', 'usd', 'date', 'platform')); return view('frontend::index', compact('kurs', 'usd', 'date', 'platform'));
} }
public function ont()
{
$json = File::get('storage/kurs.json');
$kurs = json_decode($json);
if($kurs->date != date('Y-m-d')){
$this->getKurs();
}
$json = File::get('storage/kurs.json');
$kurs = json_decode($json);
$usd = $kurs->rates->IDR/$kurs->rates->USD;
$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();
$header = $sheets->pull(0);
$posts = Sheets::collection($header, $sheets);
$posts = $posts->take(5000);
$data = new Collection($posts->toArray());
$platform = $data->random(5);
return view('frontend::ont', compact('kurs', 'usd','date','platform'));
}
public function press()
{
return view('frontend::press-release');
}
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());
@ -93,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);
@ -126,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);
@ -173,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));
} }