request('page', 1) // Get current page from request ])->json(); // Extract pagination details $items = $response['data'] ?? []; // Data array $total = $response['total'] ?? 0; // Total items $perPage = $response['per_page'] ?? 10; // Items per page $currentPage = $response['current_page'] ?? 1; // Current page // Create Laravel paginator $list = new LengthAwarePaginator($items, $total, $perPage, $currentPage, [ 'path' => request()->url(), // Current URL 'query' => request()->query(), // Append other query params ]); return view('autoserahan.index', compact('list')); } public function approve(Request $request) { $response = Http::put(config('api.url') . '/api/autoserahan/approve', [ 'id' => $request->id, 'kodcaw' => $request->kodcaw, 'teller' => $request->teller, 'amaun' => $request->amaun, 'sendApproval' => 'ACCEPTED', 'operasi_name' => auth()->user()->name, ])->json(); if($response['status'] == 'success'){ event(new AutoSerahan("Lulus",$request->id,$request->kodcaw,$request->teller)); return redirect()->route('autoserahan')->with('success', 'Serahan approved successfully'); }else{ event(new AutoSerahan("Error",$request->id,$request->kodcaw,$request->teller)); return redirect()->route('autoserahan')->with('error', 'Serahan approved failed'); } } public function reject(Request $request) { $response = Http::put(config('api.url') . '/api/autoserahan/approve', [ 'id' => $request->id, 'kodcaw' => $request->kodcaw, 'teller' => $request->teller, 'amaun' => $request->amaun, 'sendApproval' => 'REJECTED', 'operasi_name' => auth()->user()->name, ])->json(); if($response['status'] == 'success'){ event(new AutoSerahan("Batal",$request->id,$request->kodcaw,$request->teller)); return redirect()->route('autoserahan')->with('success', 'Serahan rejected successfully'); }else{ event(new AutoSerahan("Error",$request->id,$request->kodcaw,$request->teller)); return redirect()->route('autoserahan')->with('error', 'Serahan rejected failed'); } } }