/** * Show the form for creating a new resource. * * @return Response */ public function create($pb_id) { $data = ['title' => 'Form Pembuatan PO', 'asset' => new Assets(), 'js' => ['vendor/jquery-ui-autocomplete-datepicker.min'], 'css' => ['jquery-ui-autocomplete-datepicker.min'], 'position' => ['po' => 'Purchasing Order', 'po/create/' . $pb_id => 'Buat PO'], 'head' => Pb::fetchDetail($pb_id), 'sub' => Pbs::fetchForPO($pb_id), 'pb_id' => $pb_id]; return view('po.create', $data); }
public function requestUpdate(Request $req) { $rec = Pb::find($_POST['pb_id']); $rec->pb_no = trim($req->input('pb_no')); $rec->pb_tgl_butuh = $req->input('pb_tgl_butuh'); $rec->sup_id = $req->input('sup_id'); $rec->pb_note = trim($req->input('pb_note')); $rec->userid_edit = Auth::user()->user_id; $rec->save(); #delete the sub first Pbs::where('pb_id', $_POST['pb_id'])->delete(); #insert all new data $x = 0; foreach ($_POST['mat_id'] as $val) { $values = ['pb_id' => $_POST['pb_id'], 'mat_id' => $val, 'pbs_jml' => $_POST['pbs_jml'][$x]]; Pbs::create($values); $x++; } Session::flash('updated', '<div class="info success">Permintaan material berhasil diubah.</div>'); return redirect('material/request/edit/' . $_POST['pb_id']); }