public function genera_oc() { $cotizaciones = Cotizacion::whereReq_id($this->req_id)->get(); foreach ($cotizaciones as $cotizacion) { $this->oc = ''; foreach ($cotizacion->articulos as $art) { if ($art->pivot->sel == 1 && $art->oc_id == '') { if (empty($this->oc)) { $this->oc = \Consecutivo::nextOc(); $oc = new Oc(); $oc->req_id = $this->req_id; $oc->oc = $this->oc; $oc->fecha_oc = \Carbon\Carbon::now()->toDateString(); $oc->benef_id = $cotizacion->benef_id; $oc->save(); $condiciones = new OcsCondicion(); $condiciones->oc()->associate($oc); $condiciones->save(); } //Actualizar articulo con oc_id $this->actualizar_articulo($art->id, $oc->id); } } } return $this->arr_ocs; }
public function importarOcs() { $legacy_ocs = $this->consultarOcsLegacy(); foreach ($legacy_ocs as $oc_legacy) { $benef_id = $this->getBenefId($oc_legacy->benef_id); $req_id = Req::whereReq($oc_legacy->req)->pluck('id'); $oc_nueva = new Oc(); $oc_nueva->req_id = $req_id; $oc_nueva->oc = $oc_legacy->oc; $oc_nueva->fecha_oc = $oc_legacy->fecha_oc; $oc_nueva->benef_id = $benef_id; $oc_nueva->estatus = $oc_legacy->estatus; $oc_nueva->save(); } }