<?php

namespace App\Http\Controllers\Dashboard\Billing;

use App\Http\Controllers\Controller as ExController;
use App\Models\Billing;
use App\Models\Currency;
use Illuminate\Http\Request;

class Controller extends ExController
{
    public function index()
    {
        $this->authorize('view', 'billings');
        $billings = Billing::latest('id')
            ->paginate(config(50));
        $currency = Currency::latest()->first();

        return view('dashboard.billing.index', compact('billings', 'currency'));
    }

    /**
     * @param Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function search(Request $request)
    {
        $id = $request->get('query');
        $billings = Billing::where('id', $id)->orWhere('transaction_id', $id)->paginate(50);

        return view('dashboard.billing.index', compact('billings'));

    }
}
