I have linked tables and when I need to access the information I recuse the query
:
DB::table('paciente AS pac')
->leftJoin('pessoa AS p', 'p.id', '=', 'pac.id_pessoa')
->select('p.nome, pac.ficha')
->where('pac.id', '=', $id_paciente)
->orderby('ag_prof.hora_inicial')
->get();
How can I optimize, to avoid repeating this in Controller
, should I create it in model
or in what folder?