34 lines
853 B
PHP
34 lines
853 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\CompanyStatus;
|
|
use App\Services\BillplzService;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
|
|
class BillplzController extends Controller
|
|
{
|
|
public function __invoke(Request $request)
|
|
{
|
|
$companyMapping = [
|
|
'PKB',
|
|
'KOPKB',
|
|
];
|
|
|
|
$bills = array_reduce($companyMapping, function($carry, $company_code) use($request){
|
|
$billplzService = new BillplzService($company_code);
|
|
$billIdArray = json_decode($request->bill_ids);
|
|
$billIdArray = $billplzService->getBills($billIdArray);
|
|
$carry[$company_code] = array_filter($billIdArray, function($bill) {
|
|
return $bill !== [];
|
|
});
|
|
return $carry;
|
|
}, []);
|
|
|
|
return $bills;
|
|
|
|
|
|
}
|
|
}
|