0
我想使用一個輔助功能,但我得到這個錯誤在我的觀點:我的輔助功能調用未定義功能 - laravel
Call to undefined function createSubCategories()
路徑:
Http\Controllers\Utilities\Helpers.php
我hlper:
<?php
namespace App\Http\Controllers\Utilities;
function createSubCategories($parent_cat_id = 0)
{
$subs = DB::table('categories')->where('parent_cat_id', '=', $parent_cat_id)->get();
if (count($subs) > 0) {
echo '<ul>';
foreach ($subs as $sub) {
echo '<li>' . $sub->title_fa;
echo $this->createSubCategories(($sub->id));
echo '</li>';
}
echo '</ul>';
}
}
在composer.json:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files":
[
"app/Http/Controllers/Utilities/Helpers.php"
]
},
我用composer dump-autoload
。
我的觀點:
{{createSubCategories(0)}}
對不起,我沒有看到你已經回答了這個問題...... – matthiku