簡體   English   中英

Laravel 視圖變量,缺少路由所需的參數

[英]Laravel view with variable, missing required parameters for route

我為(我確定)一個小失蹤而浪費了太多時間,但我無法找到它。 這是我的問題。

我想創建一個開放的刀片,因此無需身份驗證,在 URL 中有一個可變參數。

這是我的代碼

// routes/web.php
  Route::get('/{org_id}/tickets/ext/index', array('as' => 'tickets.ext.index', 'uses' => 'Ext\ExtTicketsController@index'));


// Ext\ExtTicketsController
 public function index(Request $request, $org_id)
 {
   //$org_id = 'my_organization';
   //dd(app()->getLocale());
   $locale=substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);

   return view('tickets/ext/index')
   ->with('org_id',$org_id)
   ->with('locale',$locale);
 }

當我嘗試登陸http://localhost/app/public/en/ my_organization /tickets/ext/index 時出現錯誤,我不明白來源:

Missing required parameters for [Route: tickets.ext.index] [URI: {locale}/{org_id}/tickets/ext/index]

我將刀片放入 views/ticket/ext/index 文件。

提前致謝!

你可以像這樣簡化你的代碼,我希望它能工作

// routes/web.php
Route::get('/{org_id}/tickets/ext/index', 'Ext\ExtTicketsController@index');


// Ext\ExtTicketsController
public function index($org_id)
{
   $org_id = $org_id';
   $locale=substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
   return view('tickets.ext.index',compact('org_id','locale'));
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM