0
I have a query where I have several relationships between different tables, which would be the best way to select a specific column that is within the Function($query)
in that case the rule of ->where('produtos.id','=',$id)
And I want to get to the result where I select everything from the table id variation instead of the product table as it is currently in the code. for example:
->where('variacao.id','=',$id)
public function buscarPorId($id)
{
//$id_admin = Credencial::recuperarIdAdmin();
return $this->produto->with('descricao')
->with('produtoMarketplace')
->with(['produtoCategoria' => function ($query) {
$query->Join('categoria', 'categoria.id', '=', 'produto_categoria.id_categoria')
->Join('departamento', 'departamento.id', '=', 'categoria.id_departamento');
}
])
->with([
'variacao' => function ($query) {
$query->Join('atributo', 'atributo.variacao_id', '=', 'variacao.id')
->Join('valor_atributo', 'valor_atributo.id', '=', 'atributo.valor_atributo_id')
->Join('item_atributo', 'item_atributo.id', '=', 'valor_atributo.tipo_atributo_id');
}
])
->where('produtos.id','=',$id)
->get();
}