I need to make a select in two tables and join them with union
, until then, but I need to also get the name of the two so I can identify it in View
. >
I have tried to use getTable()
in each select , but it returns the error:
Non-static method Illuminate\Database\Eloquent\Model::getTable() should not be called statically
I also tried to get right into select
, since I've done it this way once without using Laravel
: select('tabela1 as table')
and it returns a syntax error.
What is the right way to do this?
Code:
$first = Lista::where('serie_id', $serie->id)
->select('descricao as result1');
$atividades = Avaliar::where('serie_id', $serie->id)
->select('nota as result1')
->union($first)
->get();