middleware('auth'); $this->customerService = New CustomerService(); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $search = false; $auth_user = Auth::user(); $cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json(); $bank = Http::get(config('api.url') . '/api/bank')->json(); return view('customers.index',compact('search','cawangan_info','bank')); } public function info(){ $auth_user = Auth::user(); $cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json(); return view('customers.info',compact('cawangan_info')); } public function search(Request $request){ $noic = $request->noic; $auth_user = Auth::user(); $cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $auth_user['cawangan'])->json(); $bank = Http::get(config('api.url') . '/api/bank')->json(); $customers_info = Http::get(config('api.url') . '/api/customers/'. $noic)->json(); if($customers_info){ $customer_info = $customers_info[0]; }else{ $customer_info = $customers_info; } $search = true; if($customer_info){ Session::put('customer_info',$customer_info); return redirect()->route('customer_info')->with( ['customer_info' => $customer_info,'cawangan_info'=>$cawangan_info]); }else{ return view('customers.index',compact('customer_info','search','noic','cawangan_info','bank')); } } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create(Request $request) { // dd($request); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $customer = $this->customerService->createNewCustomer($request); $customer_info = Customer::where('noic','=',$request['noic'])->first(); // dd($customer_info); Session::put('customer_info',$customer_info); return redirect()->route('customer_info')->with( ['customer_info' => $customer_info] ); } /** * Display the specified resource. * * @param \App\Customer $customer * @return \Illuminate\Http\Response */ public function show(Customer $customer) { // } /** * Show the form for editing the specified resource. * * @param \App\Customer $customer * @return \Illuminate\Http\Response */ public function edit(Customer $customer) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Customer $customer * @return \Illuminate\Http\Response */ public function update(Request $request, Customer $customer) { // } /** * Remove the specified resource from storage. * * @param \App\Customer $customer * @return \Illuminate\Http\Response */ public function destroy(Customer $customer) { // } public function test(){ $response = Http::get('http://localhost:8000/api/customers'); dd($response->json()); } }