How could I do this query in laravel:
SELECT * FROM(
SELECT * FROM `tb_horario` where cod_funcionario="'.$cod.'" and deleted_at is null)
AS temp
where temp.motivo!='' or temp.validado=0
but sometimes I dont have to use cod_funcionario because is a filter in my page
so I've something like:
if ($funcionario)
{
$horariosQuery->where('cod_funcionario', $funcionario);
}
I dont know how to do this query with this subquery in laravel like I did in sql. thxx!