Php 在重用其他项目的代码时调用Laravel中未定义的函数
我有一个blade.php,它应该生成一个菜单:Php 在重用其他项目的代码时调用Laravel中未定义的函数,php,laravel,blade,Php,Laravel,Blade,我有一个blade.php,它应该生成一个菜单: <ul class="header-nav"> @foreach(config('menu.horizontal') as $menu) <li class="{{set_active($menu['active'],'active')}} @if(isset($menu['children'])) has-child @endif"> <a href="{{$men
<ul class="header-nav">
@foreach(config('menu.horizontal') as $menu)
<li class="{{set_active($menu['active'],'active')}} @if(isset($menu['children'])) has-child @endif">
<a href="{{$menu['link']}}" @if(isset($menu['children'])) data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" @endif><i class="{{$menu['icon']}}"></i> {{$menu['title']}}</a>
@if(isset($menu['children']))
<div class="dropdown-menu">
@foreach($menu['children'] as $child)
<a class="dropdown-item" href="{{$child['link']}}">{{$child['title']}}</a>
@endforeach
</div>
@endif
</li>
@endforeach
</ul>
但是我得到了这个错误:
ErrorException in 23bb0e870ad0fbd7e21a6ce757b7bc9560d31591.php line 3:
Call to undefined function set_active() (View: C:\xampp\htdocs\myproject\resources\views\admin\layouts\partials\nav\menu-horizontal.blade.php)
我在复制它的应用程序中没有发现此错误。我检查了set_active()是否存在,它是否存在:
<?php
use App\Space\Settings\Setting;
function set_active($path, $active = 'active') {
return call_user_func_array('Request::is', (array)$path) ? $active : '';
}...
清除视图
,缓存
,生成新密钥并重新运行程序
并向存储文件夹提供755
或777
命令是
php artisan view:clear
php artisan cache:clear
php artisan key:generate
也运行
composer update
你可以很容易地尝试这个,如果效果很好,对你的项目没有伤害,它的顺势疗法:)
composer update