Skip to content

Instantly share code, notes, and snippets.

@coderdiaz
Created June 9, 2015 14:38
Show Gist options
  • Save coderdiaz/cc26d05dc79dde398420 to your computer and use it in GitHub Desktop.
Save coderdiaz/cc26d05dc79dde398420 to your computer and use it in GitHub Desktop.
Union ALL with Laravel 4.2
<?php
/**
* Funcion para obtener el historial sobre una cuenta, a partir de los trámites que ha realizado.
* @return Response JSONArray
*/
public function obtenerHistorialCuentas($account)
{
$depositos = TesDepositos::select(DB::raw('1 AS tipo,tes_depositos.deposito_id as folio, tes_depositos.deposito_importe as importe, tes_depositos.deposito_date_revision as fecha, tes_depositos.deposito_estado as estado'))
->distinct()
->where('cuenta_numero', '=', $account);
$eventos = TesEventos::select(DB::raw('2 AS tipo, tes_eventos.evento_folio as folio, tes_eventos.evento_importe as importe, tes_eventos.evento_fecha as fecha, null AS estado'))
->distinct()
->where('cuenta_numero', '=', $account);
return $depositos->unionAll($eventos->getQuery())->get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment