Laravel Spatie Laravel-nevigation路线错误

发布于 2025-02-09 20:15:16 字数 978 浏览 0 评论 0原文

我正在尝试使Spatie Laravel-Mavitation插件在Laravel 9.1.0的项目中工作 spatie laravel导航

到目前为止,我做到了:

  1. 用作曲家安装插件

  2. 安装插件

    app \ providers \ navigationProvider :: class,

  3. 添加config/app.php Aliases Aliases

    中的别名

    '导航'=> Spatie \ navigation \ navigationserviceProvider :: class,

  4. 我了解我创建了一个新的提供商

    php工匠制造:提供商导航供应商

  5. 提供商我添加到顶部

    使用spatie \ navigation \ navigation;

  6. 在手柄函数中,我添加此

    app(navigation :: class) - > add('dashboard',route('dashboard'));

我有以下错误,因为

Route [dashboard] not defined.

在我的路线/web.php中,我有以下路线。

Route::get('/', function () {
return view('pages.dashboard');
})->name('dashboard');

任何想法我想念什么。 在使路线部分工作后,我还有关如何在刀片中使用它的任何提示。

感谢您的帮助。

I'm trying to make the Spatie Laravel-Navitation plugins to work on my project in Laravel 9.1.0
Spatie Laravel Navigation

So far I did :

  1. Install the plugin with composer

  2. add the plugin to the config/app.php provider

    App\Providers\NavigationProvider::class,

  3. Add the alias in the config/app.php aliases

    'Navigation' => Spatie\Navigation\NavigationServiceProvider::class,

  4. From what I understand I create a new provider

    php artisan make:provider NavigationProvider

  5. Inside the provider I add to the top

    use Spatie\Navigation\Navigation;

  6. Inside the handle function I add this

    app(Navigation::class)
    ->add('dashboard', route('dashboard'));

I have the following error since:

Route [dashboard] not defined.

In my routes/web.php I have the following route.

Route::get('/', function () {
return view('pages.dashboard');
})->name('dashboard');

Any Idea what I miss.
Any tips also on how I will use this in the blade after making the route portion work.

Thank you for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁我热情 2025-02-16 20:15:16

我也许找到了这个问题,但我不确定这是最优雅的方法。

在我的控制器启动功能中,我做到了:

    $this->app->booted(function () {
        app(Navigation::class)
        ->add('dashboard', route('dashboard'));
    });
    view()->composer('*',function($view) {
        $view->with('navigation', app(Navigation::class)->tree() );
        $view->with('breadcrumbs', app(Navigation::class)->breadcrumbs() );
    });

I maybe found the issue but I'm not sure it's the most elegant way to do this.

In my controller boot function I did this :

    $this->app->booted(function () {
        app(Navigation::class)
        ->add('dashboard', route('dashboard'));
    });
    view()->composer('*',function($view) {
        $view->with('navigation', app(Navigation::class)->tree() );
        $view->with('breadcrumbs', app(Navigation::class)->breadcrumbs() );
    });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文