public function getNominas($idCarga) { $carga = Cargas::find($idCarga); if ($carga) { //obtener cargas $empresa = $carga->empresa()->orderBy('tipo_receptor')->get(); $sat = $carga->sat()->orderBy('tipo_receptor')->get(); $diff = new DiferenciasCFID($sat, $empresa, $carga->rfc); $ingresos = $diff->getNomina(); $array = ['rfc' => $carga->rfc, 'nombre' => $carga->contribuyente->nombre, 'ingresos' => $ingresos]; Excel::create('Nomina', function ($excel) use($array) { $excel->sheet('New sheet', function ($sheet) use($array) { $sheet->loadView('descargas.reporte-ingresos', $array); }); })->download('xlsx'); } }
public function getIngresos(Request $request) { try { $contr = $request->cont; $desde = Carbon::createFromFormat('Y-m-d', $request->desde)->startOfDay(); $hasta = Carbon::createFromFormat('Y-m-d', $request->hasta)->endOfDay(); } catch (\Exception $e) { return view('vacio'); } $sat = ArchivoSat::whereBetween('fecha', array($desde, $hasta))->where(function ($q) use($contr) { $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr); })->get(); $empresa = ArchivoEmpresa::whereBetween('fecha', array($desde, $hasta))->where(function ($q) use($contr) { $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr); })->get(); $todos = $sat->count() + $empresa->count(); if ($todos == 0) { return view('vacio'); } $diff = new DiferenciasCFID($sat, $empresa, $contr); $ingresos = $diff->getIngresos(); $contr = Contribuyente::where('rfc', '=', $contr)->first(); $array = ['nombre' => $contr->nombre, 'rfc' => $contr->rfc, 'ingresos' => $ingresos]; Excel::create('Ingresos', function ($excel) use($array) { $excel->sheet('New sheet', function ($sheet) use($array) { $sheet->loadView('descargas.reporte-ingresos', $array); }); })->download('xlsx'); }