【问题标题】:Route [song.store] not defined路线 [song.store] 未定义
【发布时间】:2019-11-30 00:33:11
【问题描述】:

http://kristijanhusak.github.io/laravel-form-builder/overview/quick-start.html Laravel 表单构建器快速入门

路线 [song.store] 未定义。

我想知道怎么写路由 这是我的礼物

Route::resource('/songs', 'Account\Controller')
       ->except([ 'show']);

【问题讨论】:

  • 您的问题没有提供足够的信息、代码和其他任何可以帮助我们理解真正问题的东西,您能否改进您的问题?
  • @atymic 肯定是重复的。

标签: php laravel


【解决方案1】:

您的路由缺少名称,您需要指定此名称,以便 laravel 为其生成 URL。

Route::resource('/songs', 'Account\Controller')
    ->except([ 'show'])
    ->name('song');

【讨论】:

    【解决方案2】:

    Laravel Route::group 的为了实现路由名称前缀的能力。

    Route::group(['prefix' => 'song', 'as' => 'song.'], function() {
        // Route::get('example', function() { return; })->name('example');
    });
    

    为了访问此路由,您必须使用其名称。

    route('song.example');
    

    考虑为您的路线命名,这应该可以解决问题。

    Route::group(['prefix' => 'song', 'as' => 'song.'], function() {
        Route::resource('songs', 'Account\Controller')
            ->except(['show'])
            ->name('songs');
    });
    

    然后可以这样调用:

    route('song.songs');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-26
      • 2021-11-12
      • 2022-01-16
      • 2018-10-15
      • 2020-09-13
      • 2017-12-25
      • 2023-03-29
      相关资源
      最近更新 更多