Search code examples
laravellaravel-routing

How do I display the value of a variable ( key ) in a html page?


my Route is :

Route::get('/dash/{$slug}', 'DashController@client');

I am currently using the below in a Controller:

public function client($slug)
    {

        $idz = Company::where('CompanyID', $slug)->first();
  return view('dashboards.companydashboard', [
            'id' => $idz
        ]);
        
        
    }

and in my html page i have :

<p>{{$id}}</p>

its not outputting the value, what am I missing


Solution

  • You route is wrong, {$slug} will be {slug} :

    Route::get('/dash/{slug}', 'DashController@client');