-1
I have to get data from 3 tables(planejamento_objetivo
, planejamento
and equipe
) and then apply a period filter and team.
Assemble query to bring up table data planejamento_objetivo
.
It will only bring the objectives that refer to the selected period, and are linked to the column planejamento_id
, from the team in question table (planejamento
equipe_id
) And that are linked with a planning (column situacao_planejamento_id
) in a situation equal to 2.
public function selecionaDados(array $filtro = [])
{
$query = DB::table('planejamento_objetivo')
->join('planejamento', 'planejamento_objetivo.planejamento_id', '=', 'planejamento.id')
->join('fase', 'planejamento.fase_id', '=', 'fase.idFase')
->select('planejamento_objetivo.id AS id',
'planejamento_objetivo.objetivo AS objetivo',
'planejamento_objetivo.prazo AS prazo',
'planejamento_objetivo.situacao_planejamento_objetivo_id AS situacao',
'planejamento_objetivo.texto_report AS report'
)
->selectRaw('DATE_FORMAT(STR_TO_DATE(prazo, "%m/%Y"), "%Y-%m") AS periodo')
->where('planejamento_objetivo.situacao_planejamento_objetivo_id', 2)
->orderBy('prazo', 'asc')
->get();
return $query->toArray();
}
I’m having more difficulties when mounting the filter.
I’d appreciate it if someone could help me.
Guys, I ask that if you’re not going to help me, at least don’t spoil my question. I am a beginner and maybe this is simple for you, but for me who am starting it is not yet. You have gone through this phase, so I ask for your understanding. Thanks
– daniel mello
In the question you speak in query with Eloquent, but the code is in Query Builder. Pass a filter via callback in Where method.
– Williams
I did that and it worked!! Sorry I didn’t know how to formulate my question right. I’m new! Thanks for the tip!!!!
– daniel mello