<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;

class RechargecardHook extends Controller
{
    public function index(Request $request){
        $input = $request->all();

        $reference= $input['reference'];
        $quantity= $input['quantity'];
        $amount= $input['amount'];
        $network= $input['network'];
        $unit_price= $input['unit_price'];
        $total_price =$input['total_price'];
        $date= $input['date'];
        $supplier= $input['supplier'];
        $pins= $input['pins'];

        foreach ($pins as $eachpin) {
            $pin= $eachpin['pin'];
            $serial= $eachpin['serial'];
            $amount= $eachpin['amount'];
            $expiry= $eachpin['expiry'];
            $reference= $eachpin['reference'];
            $id= $eachpin['id'];
            $network= $eachpin['network'];
            
            DB::table('pins')->insert(['pin' => $pin, 'serial' => $serial, 'network' => $network, 'amount' =>$amount]);
        }
        return "success";
    }
}
