// Modelo Cliente
public function plano()
{
return $this->hasManyThrough('App\Plano', 'App\Plano_cliente','cliente_id','id','plano_id');
}
//Modelo Plano
public function cliente()
{
return $this->hasManyThrough('App\Cliente', 'App\Plano_cliente','plano_id','id','cliente_id');
}
// Modelo Plano_cliente
protected function cliente(){
return $this->belongsToMany('App\Cliente')->withPivot('cliente_id', 'id');
}
protected function plano(){
return $this->belongsToMany('App\Plano')->withPivot('plano_id', 'id');
}
These are the three models Customer - > customer-plan
When I ask: Client :: with (flat) -> get ();
returns in the resultset all clients but only the foreground of each Can have multiple plans each client