public static function editar($input) { $respuesta = array(); $reglas = array(); $validator = Validator::make($input, $reglas); if ($validator->fails()) { $respuesta['mensaje'] = $validator; $respuesta['error'] = true; } else { $texto = Texto::find($input['texto_id']); // $texto->cuerpo = $input['cuerpo']; // // $texto->save(); $lang = Idioma::where('codigo', App::getLocale())->where('estado', 'A')->first(); $texto_lang = Texto::join('texto_lang', 'texto_lang.texto_id', '=', 'texto.id')->where('texto_lang.lang_id', $lang->id)->where('texto.id', $texto->id)->first(); $datos = array('cuerpo' => $input['cuerpo']); $texto_modificacion = DB::table('texto_lang')->where('id', $texto_lang->id)->update($datos); if (isset($input['descripcion'])) { $input['descripcion'] = $input['descripcion']; } else { $input['descripcion'] = NULL; } $item = Item::editarItem($input); $respuesta['mensaje'] = 'Texto modificado.'; $respuesta['error'] = false; $respuesta['data'] = $texto; } return $respuesta; }
public function texto() { return Texto::find($this->texto_id); }