升级Laravel 5.8到6.0之后,错误缺少[路由]所需的参数

发布于 2025-01-21 20:42:53 字数 1796 浏览 5 评论 0原文

升级后 Laravel 5.8 6.0 我得到以下错误:

local.error:[路由: playlist-song.show] [uri:public/admin/playlist-song/{playlist_song}]。 {“ userId”:1,“异常”:“ [对象] (照明\ routing \ exceptions \ urlgenerationException(代码: 0):[路由:playlist-song.show]缺少所需的参数] [uri: public/admin/playlist-song/{playlist_song}] /var/www/vendor/laravel/framework/src/illuminate/routing/exceptions/urlgenerationexpection.php:17)

Inspect结果:

“

我试图使用_ 或-,但仍然无法解决此错误:

解决此问题的想法吗?

预先感谢您...

===更新

  1. 我怀疑此处的错误:
$datatables = app('datatables')->of($model)
 ->addColumn('action', function ($model) {
                return "<a href='". route('playlist-song.show', ['id' => $model->id]) ."' class='btn btn-success btn-sm'><i class='fa fa-eye'></i></a>" . 
                        " <a href='". route('playlist-song.edit', ['id' => $model->id]) . "' class='btn btn-primary btn-sm'><i class='fas fa-pencil-alt'></i></a>" .
                        " <a href='#' onClick='modalDelete(".$model->id.")' class='btn btn-sm btn-danger'><i class='fas fa-trash'></i></a>";                        
});
  1. 更新以下URL仍然无法解决问题:

href ='”。{{route('playlist-song.show',['playlist-song'=&gt; $ model]) }}。”'

href =“ {{route('playlist-song.show', ['playlist-song'=&gt; $模型])}}“

After upgrading Laravel 5.8 to 6.0 I get the below error:

local.ERROR: Missing required parameters for [Route:
playlist-song.show] [URI: public/admin/playlist-song/{playlist_song}].
{"userId":1,"exception":"[object]
(Illuminate\Routing\Exceptions\UrlGenerationException(code:
0):Missing required parameters for [Route: playlist-song.show] [URI:
public/admin/playlist-song/{playlist_song}].at
/var/www/vendor/laravel/framework/src/Illuminate/Routing/Exceptions/UrlGenerationException.php:17)

Chrome Inspect Result:

chrome inspect error for laravel

I have tried to find error and update route using _ or - but still can't solve this error:

any idea to solve this issue?

Thank You in Advance...

===Update

  1. I suspect error here:
$datatables = app('datatables')->of($model)
 ->addColumn('action', function ($model) {
                return "<a href='". route('playlist-song.show', ['id' => $model->id]) ."' class='btn btn-success btn-sm'><i class='fa fa-eye'></i></a>" . 
                        " <a href='". route('playlist-song.edit', ['id' => $model->id]) . "' class='btn btn-primary btn-sm'><i class='fas fa-pencil-alt'></i></a>" .
                        " <a href='#' onClick='modalDelete(".$model->id.")' class='btn btn-sm btn-danger'><i class='fas fa-trash'></i></a>";                        
});
  1. Update the URL like below still can not solve the problem:

href='". {{ route('playlist-song.show', ['playlist-song' => $model])
}}."'

href="{{ route('playlist-song.show',
['playlist-song' => $model]) }}"

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

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

发布评论

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

评论(2

血之狂魔 2025-01-28 20:42:53

您的错误告诉您您的playlist_song参数缺少。您需要指定其值。尝试的是

$datatables = app('datatables')->of($model)
 ->addColumn('action', function ($model) {
                return "<a href='". route('playlist-song.show', ['playlist_song' => $model->id]) ."' class='btn btn-success btn-sm'><i class='fa fa-eye'></i></a>" . 
                        " <a href='". route('playlist-song.edit', ['playlist_song' => $model->id]) . "' class='btn btn-primary btn-sm'><i class='fas fa-pencil-alt'></i></a>" .
                        " <a href='#' onClick='modalDelete(".$model->id.")' class='btn btn-sm btn-danger'><i class='fas fa-trash'></i></a>";                        
});

指定参数。如果您仍然有问题,请让我知道您的新错误消息/问题是什么。

Your error tells you that your playlist_song parameter is missing. You will need to specify its value. A try would be

$datatables = app('datatables')->of($model)
 ->addColumn('action', function ($model) {
                return "<a href='". route('playlist-song.show', ['playlist_song' => $model->id]) ."' class='btn btn-success btn-sm'><i class='fa fa-eye'></i></a>" . 
                        " <a href='". route('playlist-song.edit', ['playlist_song' => $model->id]) . "' class='btn btn-primary btn-sm'><i class='fas fa-pencil-alt'></i></a>" .
                        " <a href='#' onClick='modalDelete(".$model->id.")' class='btn btn-sm btn-danger'><i class='fas fa-trash'></i></a>";                        
});

This specifies the parameter. If you still have problems, then let me know what your new error message/problem is.

雪若未夕 2025-01-28 20:42:53

您可以通过使用视图作为以下内容来执行此操作:

$datatables = app('datatables')->of($model)
 ->addColumn('action', function($model) {
                return view('partial.action', compact('model'));
            });

创建您想要的视图,并且可以将其放入正常的HTML代码而无需串联和任何其他问题的

刀片文件:

 <a href="{{ route('playlist-song.show', ['id' => $model->id]) }}" class='btn btn-success btn-sm'><i class='fa fa-eye'></i></a>
 <a href="{{ route('playlist-song.edit', ['id' => $model->id]) }}" class='btn btn-primary btn-sm'><i class='fas fa-pencil-alt'></i></a>
 <a href='#' onClick="modalDelete('{{$model->id}}')" class='btn btn-sm btn-danger'><i class='fas fa-trash'></i></a>

you can do this by using view also as the following:

$datatables = app('datatables')->of($model)
 ->addColumn('action', function($model) {
                return view('partial.action', compact('model'));
            });

create your view where you want, and you can put inside it normal html code without concatenation and any other issue

the blade file :

 <a href="{{ route('playlist-song.show', ['id' => $model->id]) }}" class='btn btn-success btn-sm'><i class='fa fa-eye'></i></a>
 <a href="{{ route('playlist-song.edit', ['id' => $model->id]) }}" class='btn btn-primary btn-sm'><i class='fas fa-pencil-alt'></i></a>
 <a href='#' onClick="modalDelete('{{$model->id}}')" class='btn btn-sm btn-danger'><i class='fas fa-trash'></i></a>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文