Closed andreshg112 closed 7 years ago
return $this->belongsToThrough(Sede::class, [ ['vendedor_id', Vendedor::class] ]);
Doing this:
public function sede() { return $this->belongsToThrough(Sede::class, [ ['vendedor_id', Vendedor::class] ]); }
I'm getting this:
`FatalErrorException in BelongsToThrough.php line 40: Class 'vendedor_id' not found
in BelongsToThrough.php line 40
`
Oh! My bad.
return $this->belongsToThrough(Sede::class, [ [Vendedor::class, 'vendedor_id'] ]);
There is an example in tests. I guess this needs to be documented.
I need to do something like this:
But when I do it, I got this:
QueryException in Connection.php line 729: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pedidos.vendedor_idvendedore_id' in 'on clause' (SQL: select
sedes.*,
pedidos.
idas
__deep_related_through_keyfrom
sedesleft join
vendedoreson
sedes.
id=
vendedores.
sede_idleft join
pedidoson
vendedores.
id=
pedidos.
vendedor_idvendedore_idwhere
pedidos.
idin (2997, 2998) and
sedes.
deleted_atis null)
When I do it without the key and array:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pedidos.vendedore_id' in 'on clause' (SQL: select
sedes.*,
pedidos.
idas
__deep_related_through_keyfrom
sedesleft join
vendedoreson
sedes.
id=
vendedores.
sede_idleft join
pedidoson
vendedores.
id=
pedidos.
vendedore_idwhere
pedidos.
idin (2997, 2998) and
sedes.
deleted_atis null)
I have a problem with it because you're using Str::singular. This is just for english words. How can I change the name of my foreign key? Note: The plural for 'vendedor' is 'vendedores', in spanish.