I have the following code:
use app\models\Kategorije;
function hasMoreParent($id,$i = 0){
$model = new Kategorije();
$parent_id = $model::find()->where('id = :id',[':id' => $id])->one()->parent_id;
if ($parent_id > 1) {
$i++;
hasMoreParent($parent_id,$i);
}
return $i;
}
And, if $i is greater than 0 it always returns 1 instead of 2 or 3.. How can I make it to return those other numbers?