Created
June 9, 2015 14:38
-
-
Save coderdiaz/cc26d05dc79dde398420 to your computer and use it in GitHub Desktop.
Union ALL with Laravel 4.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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