Skip to content
Advertisement

Laravel view with variable, missing required parameters for route

I am losing too much time for (I am sure) a small missing, but I am not able to find it. Here my issue.

I want to create an open blade, so without authentication, with a variable parameter in the URL.

Here my codes

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


// ExtExtTicketsController
 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);
 }

When I try to land on http://localhost/app/public/en/my_organization/tickets/ext/index I get error, for which I don’t understand origin:

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

I have the blade into views/ticket/ext/index file.

Thanks in advance!

Advertisement

Answer

You can simplify your code like this, I hope it’ll work

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


// ExtExtTicketsController
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'));
}
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement