2017-09-24 76 views
0

我正在使用Laravel應用程序。我需要在視圖文件中的項目文件夾中路由collaborator.blade.php文件。我有下面的表格和填寫表格數據後保存它需要重定向到collaborator.blade.php文件。我的表格與項目控制器一起工作如何在laravel中路由我的刀片文件5.2

$project = new Project; 
     $project->project_name = $request->input('name'); 
     $project->project_status = $request->input('status'); 
     $project->group   = $request->input('group'); 
     $project->color   = $request->input('color'); 
     $project->project_notes = $request->input('notes'); 
     $project->user_id  = Auth::user()->id; 

     $duplicate = Project::where('project_name',$project->project_name)->first(); 
     if($duplicate) 
     { 
      return redirect()->route('projects.index')->with('warning','Title already exists'); 
     } 

     $project->save(); 

     return redirect()->route('projects.collaborators')->with('info','Your Project has been created successfully'); 
    } 

但是當我點擊表單按鈕系統時,發生了這樣的錯誤消息。

Route [projects.collaborators] not defined. 

如何解決這個問題? 編輯 新航線

Route::get('/collaborators', function(){ 
    return view('projects.collaborators'); 
}); 

然後發生以下錯誤消息

Route [projects.collaborators] not defined. 

回答

0

你必須設置route名稱,如果我看到它的權利,你可以試試這個:

Route::get('/collaborators', function(){ return view('projects.collaborators'); })->name('yourroutename');

,然後你可以調用類的路線:

return redirect()->route('yourroutename');

0

App/Http/routes.php指向你的collaborator.blade.php和名稱只需創建一個路由它projects.collaborators

Route::get('/collaborators', function(){ 
    return view('collaborator.blade.php'); 
})->name('projects.collaborators'); 
+0

路線需要在'routes.php'which可以在laravel根目錄下'應用程序中找到/ Http'請參閱https://github.com/laravel/laravel/blob/5.2/app/Http/routes.php – chilly

+0

請參閱我已編輯的答案 – John