-1
Next, on my model
:
public function indicacao()
{
return $this->hasMany(User::class, 'indicacao','name');
}
public function todasindicacoes()
{
return $this->indicacao()->with('todasindicacoes');
}
and my controller
thus
public function rede()
{
$Usuarios = User::where('name', 'admin')->with('todasindicacoes')->get();
//dd($Usuarios);
$cont = 1;
foreach($Usuarios as $usuario){
$x = $usuario->todasindicacoes;
echo $x;
}
in the end it returns me a result and that search and other result and so infidelity, I would like to know and if it has as many times as it ran, Yeah, I got this on the bench
|login | indicacao |
|---------|-----------|
|matheus | null |
|fulano | matheus |
|beltrano | matheus |
|ciclano | beltrano |
Matheus is level 0
fulano and beltrano is level 1
and Ciclano is level 2
You want to know how many times the query was executed to return this data?
– Valdeir Psr
n exactly, I want to know, in q level so-and-so is, in the case of the example beltrano ta no 2
– Matheus Gonzales
->with('todasindicacoes')
this is not correct for this particular case, it is not ascope
that you need to create?– novic
Dude, I’m still new to Latin, but in this case it’s working just the way I want it, good almost rsrsrs
– Matheus Gonzales