/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postStore(Request $request)
 {
     $record = new Record();
     $id = $request->input("patientID");
     $record->pt_id = $id;
     $record->diagnosis = $request->input("diagnosis");
     $record->treatment = $request->input("treatment");
     $presName = "";
     $presQty = "";
     $val = $request->input("xy");
     for ($count = 1; $count < $val + 1; $count++) {
         $presName .= $request->input("drug_" . $count);
         $presQty .= $request->input("drug_" . $count . "_qtt");
         $presName .= "#";
         $presQty .= "#";
     }
     $record->pres_med = $presName;
     $record->dispenseQuantity = $presQty;
     $record->save();
     $state = Queue::find($id);
     //retrieve whole row
     if (!is_null($state)) {
         $state->status = 'Payment';
         $state->save();
     }
     $todispense = new Dispensary();
     $todispense->case_ref = $record->id;
     $todispense->dispensed_drug_code = "{$presName}";
     $todispense->dispensed_quantity = "{$presQty}";
     $todispense->save();
     //other fields in this table is to be filled by nurse using DispensaryController
     return redirect()->action('DocController@index');
 }
 public function dispense($ic, $name)
 {
     $getID = Patient::where('pt_ic', $ic)->first();
     //whole row
     $deID = $getID->id;
     //get the id from the ic
     $getcaseID = Record::where('pt_id', $deID)->first();
     $caseID = $getcaseID->id;
     $disData = Dispensary::where('case_ref', $caseID)->first();
     //xpe pakai first() sbb setiap case unik, case lain xpakai id ni
     $arrQty = explode("#", $disData->dispensed_quantity);
     $arrDrug = explode("#", $disData->dispensed_drug_code);
     //need declare $prices array x?
     $prices = array();
     for ($x = 0; $x < count($arrDrug) - 1; $x++) {
         //get price of each drug into an array
         $hehe = Inventory::where('drug_name', $arrDrug[$x])->first();
         $prices[$x] = $hehe->spu;
     }
     // $arrOne = count($arrDrug);
     // arr1 = druglist , arr2= respective qty of drug, arr3= respective price of drug
     $panel = Panel::all();
     return view('staff.dispensary')->with('name', $name)->with('arr2', $arrQty)->with('arr1', $arrDrug)->with('arr3', $prices)->with('panel', $panel)->with('ptid', $deID);
 }