Next, in my model
:
public function indicacao()
{
return $this->hasMany(User::class, 'indicacao','name');
}
public function todasindicacoes()
{
return $this->indicacao()->with('todasindicacoes');
}
and my controller
so
public function rede()
{
$Usuarios = User::where('name', 'admin')->with('todasindicacoes')->get();
//dd($Usuarios);
$cont = 1;
foreach($Usuarios as $usuario){
$x = $usuario->todasindicacoes;
echo $x;
}
At the end of the day this returns me a result and that search and other result and so infimamente, I would like to know and if you have how many times and this has run, because in the bank I have
|login | indicacao |
|---------|-----------|
|matheus | null |
|fulano | matheus |
|beltrano | matheus |
|ciclano | beltrano |
-
matheus is level 0
-
so and so beltran is level 1
-
and cyclane is level 2