I'm trying to list categories with the recursive function in CI 4, but I couldn't. The code is below and the error message is below
public function categoryList($list, $parent = 0)
{
$model = new BirimlerModel();
$list = $model->findAll();
echo '<ul>';
foreach ($list as $category){
if ($category['birim_ust'] == $parent){
echo'<li>' . $category['birim_adi'];
echo categoryList($list, $category['birim_id']);
echo '</li>';
}
}
echo '</ul>';
echo categoryList($list);
}
Error message:
ArgumentCountError Too few arguments to function App\Controllers\Yonetim\Birimler::categoryList(), 0 passed in C:\xampp\htdocs\dentisthys\system\CodeIgniter.php on line 918 and at least 1 expected