<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Auth;

class MarhunController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index(Request $request){
        $norujukan = $request->norujukan;

        $auth_user = Auth::user();

        $jemas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/jemas/'. $auth_user['cawangan'])->json();
        $hargaemas = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/harga_emas')->json();
        $cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json();
        return view('marhun.index',compact('cawangan_info','norujukan','jemas','hargaemas'));
    }
}
