<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Pembayaran;

use Carbon\Carbon;

use Illuminate\Support\Facades\DB ;

class laporanKeuanganController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
     
     
        $search = \Request::get('search');
        $pembayarans = Pembayaran::where('nama','like','%'.$search.'%')->orderBy('id')->paginate(10);

        $total = 0;

        foreach ($pembayarans as $pembayaran) {
            $total += $pembayaran->total_harga;
        }
        
        return view('laporanKeuangan.index',['pembayarans' => $pembayarans, 'total' => $total]);
    }



    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    
}

