如何更改 laravel AdminLTE 的菜单配置,而不是菜单图标(如链接)。我需要根据数据库在运行时更新徽标

How to change the Menu configuration of laravel AdminLTE, other than the menu Icons (like the links). I need to update the logo on runtime based on DB

我需要根据数据库中的值在运行时更新 Laravel AdminLTE 上的徽标,因为目前它由 adminlte.php 配置文件处理。 我尝试使用 View Composers 将一个全局变量(比如 $logoUrl)传递给每个视图,然后我使用 javascript 更改徽标 src 值。

document.addEventListener("DOMContentLoaded", function(){
    document.getElementsByClassName('brand-image')[0].src = "{{ $logoUrl}}"
})

这可行,但需要一瞬间才能在页面加载后反映出来。

有更好的方法吗?

如果您正在使用此包 https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Views-Customization

然后,如果您需要通过 运行 此命令自定义视图,您就可以发布这些视图: php artisan adminlte:install --only=main_views

Here you can read about customising the views.