im working with laravel and php, im doing a recursive function, the problem is that the return
value of the function doesnt work just work echo
.
The code is the this.
public function getSitioPadre($id){
$padre = md_sitio_espacios::where([['SITIO_ESPACIOS_ID','=',$id]])->get()->toArray();
if($padre[0]["PADRE"] == 0){
return $padre[0]["SITIO_ESPACIOS_ID"];
}else{
$this->getSitioPadre($padre[0]["PADRE"]);
}
}
When i call this function like :
echo $this->getSitioPadre(54);
returns nothing,
If in the function i use : echo $padre[0]["SITIO_ESPACIOS_ID"]
instead of return
it works.
Let me know what can i do, thank you.