[英]Route not defined in Laravel 5.2
In My Laravel App I need dispaly collaborators from My collaborators table. 在My Laravel应用程序中,我需要来自My collaborators表的显示协作者。 I wrote a query on Collaboration Model as follow
我在协作模型上写了一个查询如下
public function scopeColabo($query){
return $query->where('collaborator_id', Auth::user()->id);}
and this is My CollaborationController function for this 这是我的CollaborationController功能
public function newCol(){
$collaborators = Collaboration::colabo()->get();
return view('collaborators.new')->withCollaboration($collaborators); }
and I have link in My app.blade.php for this display as 我在我的app.blade.php中有链接显示为
<li> <a href="{{ route('collaborators.new') }}">Collaborate</a> </li>
and this is My routes.php 这是我的routes.php
Route::post('projects/{projects}/collaborator', [
'uses' => 'ProjectCollaboratorsController@newCol',
'as' => 'projects.collaborators.collaborator',]);
but I get following error message 但我收到以下错误消息
Route [collaborators.new] not defined. (View: C:\Users\fernando\Desktop\c\resources\views\layouts\app.blade.php)
what can I do to fix this problem? 我该怎么做才能解决这个问题?
I think the problem is you are indeed trying to call a route that does not exist. 我认为问题是你确实试图调用一条不存在的路线。 In your routes file you are labelling the route
'as' => 'projects.collaborators.collaborator'
so with that being said, this should be updated as such: 在您的路线文件中,您将路线标记为
'as' => 'projects.collaborators.collaborator'
所以说这应该更新如下:
<li> <a href="{{ route('projects.collaborators.collaborator') }}">Collaborate</a> </li>
EDIT: Apologies, pasted the wrong line of code from your sample. 编辑:抱歉,从您的示例中粘贴了错误的代码行。 The line above needs to be updated.
上面的行需要更新。
I did it with My routes.php paste this code 我使用My routes.php粘贴此代码
Route::resource('collaborators', 'ProjectCollaboratorsController');
it is working 这是工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.