$this->getValue($item,'n',''), 'id'=> $this->getValue($item,'idfactura',''), 'serie'=> $this->getValue($item,'serie',''), 'numero'=> $this->getValue($item,'numero',''), ]; } /*especificar los campos a validarse */ public $validate = []; /* function de devuelve una coleccion de elementos de acuerdo a la opcion requerida */ public function selects($option = null, $value = null, $request = null) { try { switch (isset($option) ? $option : '') { case 'fill': return $this->getArray($this->orderBy('idfactura','asc')->get()); case 'code': return $this->getArray($this->where('id', $this->getValue($value))->get(), false); case 'cliente': return $this->getArray($this->where('idcliente', $this->getValue($value,null,0))->get()); case 'name': return $this->getArray($this->where('nombre',$this->getValue($value))->get(), false); case 'like': return $this->getArray($this->where('nombre', 'LIKE', '%'.(isset($value) ? ucwords($value) : '').'%')->where('id','!=','1')->orderBy('nombre','asc')->get()); case 'firt': return $this->getArray($this->where('idfactura', '!=', '0')->orderBy('idfactura', 'asc')->take($this->getValue($value,null,1))->get()); case 'last': return $this->getArray($this->where('idfactura', '!=', '0')->orderBy('idfactura', 'desc')->take($this->getValue($value,null,1))->get()); default: return $this->defaultOptionInvalid; } } catch (\Exception $ex) { return $ex-getMessage(); } } public function inserts($request){ if($this->isValid($request)){ if($this->isUnique($request,'nombre','name')){ $res=null; try { $o = new Personal(); $o->documento = $this->getValue($request->documento); $o->nombre = strtoupper($request->nombre); $o->appaterno = strtoupper($request->appaterno); $o->apmaterno = strtoupper($request->apmaterno); $o->sueldo = $this->getValue($request->sueldo,null,'0.00'); $o->celular = $this->getValue($request->celular); $o->direccion=strtoupper( $this->getvalue($request->direccion)); $o->correo = $this->getValue($request->correo); $o->fechaing = $this->getValue($request->fechaing,null,null); $o->estado = '1'; $o->activo = '1'; $o->pensionaporte = $this->getValue($request->pensionaporte,null,'0.00'); $o->pensionporcentaje = $this->getValue($request->pensionporcentaje,null,'0.00'); $o->essalud =$request->essalud; $o->essaludporcentaje = $this->getValue($request->essaludporcentaje,null,'0.00'); $o->current_user = 1; $o->cargo_id = $this->getValue($this->getObject($request->cargo)->id,null,0); $o->pension_id = $this->getValue($this->getObject($request->pension)->id,null,0); $o->empresa_id = $this->getValue($this->getObject($request->empresa)->id,null,0); $o->operacioncliente_id = $this->getValue($this->getObject($request->operacioncliente)->id,null,0); $o->sexo_id = $this->getValue($this->getObject($request->sexo)->id,null,0); $o->nacionalidad_id = $this->getValue($this->getObject($request->nacionalidad)->id,null,0); $o->estadocivil_id = $this->getValue($this->getObject($request->estadocivil)->id,null,0); $res = (function ($o) {return $o->save() ? (function ($o) {return $this->response('Los datos de personal '.$o->nombre.' '.$o->appaterno.' '.$o->apmaterno.' fueron registrados correctamente',1); })($o) : (function () {return $this->response('err'); })(); })($o); } catch(\Exception $e){ $res = $this->response($e->getMessage(),0); } return $res; }else{ return $this->response('El nombre ['.$request->nombre.'] ya se encuentra registrado en el sistema, intente con un nuevo nombre.',2);} }else{return $this->response($this->getError(),0);} } }